Tiger学习 之 Arrarys

toString方法:直接输出数组的各个元素的值
引用

String[] str1 = {"a","b","c"} ;
System.out.println("str1 values are  :  "+Arrays.toString(str1));

输出:str1 values are  :  [a, b, c]       


deepToString方法:直接输出多维数组的各个元素的值
引用

String[][] str2 = {{"a","aa"},{"b","bb"},{"c","cc"}};
System.out.println("str2 values are:  "+Arrays.deepToString(str2));

输出:str2 values are:  [[a, aa], [b, bb], [c, cc]]


equals方法:比较两个数组的值是否相等
引用

String[] str1 = {"a","b","c"} ;
String[] str2 = {"a","b","c"} ;
if  (Arrays.equals(str1, str2))
System.out.println("str1 and str2 are equal.");
else
System.out.println("str1 and str2 are not equal.");

输出:str1 and str2 are equal.


deepEquals方法:比较两个多维数组的值是否相等
引用

String[][] str1 = {{"a","aa"},{"b","bb"},{"c","cc"}};
String[][] str2 = str1.clone();

if  (Arrays.deepEquals(str1, str2))
System.out.println("str1 and str2 are equal.");
else
System.out.println("str1 and str2 are not equal.");

输出:str1 and str2 are equal.


fill方法:一维数组的填值
引用

String[] str1 = new String[2];
Arrays.fill(str1, "{abc}");
System.out.println("str1 values are: "+Arrays.toString(str1));

输出:str1 values are: [{abc}, {abc}]



hashCode,deepHashCode 方法:取得数组的hashCode和deepHashCode值。
sort 方法:对数组元素进行排序

你可能感兴趣的:(C++,c,C#)