我有这个问题,但我不知道它在哪里出错。与阵列相关
int[] first = new int[2];
first[0] = 3;
first[1] = 7;
int[] second = new int[2];
second[0] = 3;
second[1] = 7;
// print the array elements
System.out.println("first = [" + first[0] + ", " + first[1] + "]");
System.out.println("second = [" + second[0] + ", " + second[1] + "]");
// see if the elements are the same
if (first[] = second[]) {
System.out.println("They contain the same elements.");
} else {
System.out.println("The elements are different.");
}
预期出放应该是这样的,例如:
first = [3, 7]
second = [3, 7]
They contain the same elements.
评论http://stackoverflow.com/questions/8777257/equals-vs-arrays-equals-in-java –