M
Miss Michelle. Heigardt
Hallo, I have written this. It prints "false" and I do not know why. I
think it should print "true". If you can help I would thank you.
Thank you
Michelle
public static void main(String[] args)
{
int i[][]=new int[3][3];
i[1][2]=4;
int j[][]=new int[3][3];
j[1][2]=4;
System.out.println(java.util.Arrays.equals(i,j));
}
Here is something I copied from here saying it should print "true".
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#equals(byte[], byte[])
public static boolean equals(int[] a,
int[] a2)
Returns true if the two specified arrays of ints are equal to one
another. Two arrays are considered equal if both arrays contain the
same number of elements, and all corresponding pairs of elements in the
two arrays are equal. In other words, two arrays are equal if they
contain the same elements in the same order. Also, two array references
are considered equal if both are null.
Parameters:
a - one array to be tested for equality.
a2 - the other array to be tested for equality.
Returns:
true if the two arrays are equal.
think it should print "true". If you can help I would thank you.
Thank you
Michelle
public static void main(String[] args)
{
int i[][]=new int[3][3];
i[1][2]=4;
int j[][]=new int[3][3];
j[1][2]=4;
System.out.println(java.util.Arrays.equals(i,j));
}
Here is something I copied from here saying it should print "true".
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#equals(byte[], byte[])
public static boolean equals(int[] a,
int[] a2)
Returns true if the two specified arrays of ints are equal to one
another. Two arrays are considered equal if both arrays contain the
same number of elements, and all corresponding pairs of elements in the
two arrays are equal. In other words, two arrays are equal if they
contain the same elements in the same order. Also, two array references
are considered equal if both are null.
Parameters:
a - one array to be tested for equality.
a2 - the other array to be tested for equality.
Returns:
true if the two arrays are equal.