Arrays中的equals()比较的是在内存中的地址值,String中的equals()比较的是内容
对于一位数组,equals()和deepEquals()没区别,但是对于多维数组则要用deepEquals()
Char[] char1 = {"C","h","i","n","a"};
Char[] char2 = {"C","h","i","n","a"};
System.out.println(Arrays.equals(char1,char2));//true
System.out.println(Arrays.deepEquals(char1,char2));//true
Char[][] char3 = {{"C","h","i","n","a"},{"J","a","p","a","n"}};
Char[][] char4 = {{"C","h","i","n","a"},{"J","a","p","a","n"}};
System.out.println(Arrays.equals(char3,char4));//false
System.out.println(Arrays.deepEquals(char3,char4));//true
如果两个数组用equals()比较后结果为true,则用deepEquals()的结果也为true |