public class Test03 {
/**
* @param args
*/
public static void main(String[] args) {
//声明数组一个长度为5的数组
String[] aArray = new String[5];
System.out.println(aArray.length);
//声明自定义内容数组,内容的多少决定了数组的长度
String[] bArray = {"a","b","c"};
String bArrayString = Arrays.toString(bArray);//Arrays.toString是调用的一个方法,然后可以输出这个数组
System.out.println(bArrayString);
//声明数组
String[] cArray = new String[]{"a","b","c","d"};
String cArrayString = Arrays.toString(cArray);
System.out.println(cArrayString);
//从一个数组创建数组列表
String[] dArray = {"a","b","c","d","e"};
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(dArray));
System.out.println(arrayList);
//检查一个数组是否包含某个值
String[] eArray = {"a","b","c","d","e"};
boolean contains = Arrays.asList(eArray).contains("f");
System.out.println(contains);
//连接俩个数组
String[] aint = {"1","2","3","4"};
String[] bint = {"5","6","7","8"};
//int[] addAll = ArrayUtils.addAll(aint, bint);
//System.out.println(addAll);
ArrayList<String> strList = new ArrayList<String>();
strList.add(Arrays.toString(aint));
strList.add(Arrays.toString(bint));
System.out.println(strList);
//把提供的数组元素放入一个字符串
//String join = StringUtils.join(new String[] {"a","b","c"}, ",");
//System.out.println(join);
//将一个数组列表转换为数组
String[] stringArray = {"a","b","c","d","e"};
ArrayList<String> arrayList2 = new ArrayList<String>(Arrays.asList(stringArray));
String[] strarr =new String[arrayList2.size()];
arrayList2.toArray(strarr);
for(String s : strarr){
System.out.print(s+" ");
}
System.out.println();
//将一个数组转换为集
String[] s1 = {"a","b","c","d","e"};
HashSet<String> set = new HashSet<String>(Arrays.asList(s1));
System.out.println(set);
//逆向一个数组
int [] i1={1,2,3,4,5};
//ArrayUtils.reverse(i1);
//System.out.println(Arrays.toString(i1));
//移除数组中的元素
int[] i2={1,2,3,4,5};
//int[] removed = ArrayUtils.removeElement(intArray, 3);//create a new array
//System.out.println(Arrays.toString(removed));
//将整数换为字节数组
byte[] bytes = ByteBuffer.allocate(4).putInt(8).array();
for(byte t : bytes){
System.out.format("0x%x ", t);
}
}
}