6. 将数组元素加入到一个独立的字符串中(Joins the elements of the provided array into a single String)
[js] view plaincopy
1.// containing the provided list of elements
2.// Apache common lang
3.String j = StringUtils.join(new String[] { "a", "b", "c" }, ", ");
4.System.out.println(j);
5.// a, b, c
7. 将数组列表转换成一个数组 (Covnert an ArrayList to an array)
[js] view plaincopy
1.String[] stringArray = { "a", "b", "c", "d", "e" };
2.ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
3.String[] stringArr = new String[arrayList.size()];
4.arrayList.toArray(stringArr);
5.for (String s : stringArr)
6. System.out.println(s);
8. 将数组转换成一个集合(Convert an array to a set)
[js] view plaincopy
1.Set<String> set = new HashSet<String>(Arrays.asList(stringArray));
2.System.out.println(set);
3.//[d, e, b, c, a]
9. 反向数组(Reverse an array)
[js] view plaincopy
1.int[] intArray = { 1, 2, 3, 4, 5 };
2.ArrayUtils.reverse(intArray);
3.System.out.println(Arrays.toString(intArray));
4.//[5, 4, 3, 2, 1]
10. 删除数组元素(Remove element of an array)
[js] view plaincopy
1.int[] intArray = { 1, 2, 3, 4, 5 };
2.int[] removed = ArrayUtils.removeElement(intArray, 3);//create a new array
3.System.out.println(Arrays.toString(removed));
One more – convert int to byte array