To my understanding, the following code should print true
, since both elements are equal
.
From java docs Array.get() will return:
Returns the value of the indexed component in the specified array object. The value is automatically wrapped in an object if it has a primitive type.
However, when I run the following code it is printing
false
:
public class Test1 {
static boolean equalTest(Object array1, Object array2) {
return Array.get(array1, 0).equals(Array.get(array2, 0));
}
public static void main(String[] args) {
int[] a = new int[1];
byte[] b = new byte[1];
a[0] = 3;
b[0] = 3;
System.out.println(equalTest(a, b));
}
}
My question is isn't classes implementing Number are or should be directly comparable to one another.