public class ByteArr {
public static void main(String[] args){
Byte[] a = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00};
Byte[] b = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00};
byte[] aa = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00};
byte[] bb = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00};
System.out.println(a);
System.out.println(b);
System.out.println(a == b);
System.out.println(a.equals(b));
System.out.println(aa);
System.out.println(bb);
System.out.println(aa == bb);
System.out.println(aa.equals(bb));
}
}
I do not know why all of them print false.
When I run "java ByteArray", the answer is "false false false false".
I think the a[] equals b[] but the JVM is telling me I am wrong, why??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…