how to compare the Java Byte[] array?

后端 未结 15 2367
囚心锁ツ
囚心锁ツ 2020-12-13 01:17
public class ByteArr {

    public static void main(String[] args){
        Byte[] a = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00};
        Byte[] b = {(byte)0x         


        
15条回答
  •  不思量自难忘°
    2020-12-13 02:02

    As byte[] is mutable it is treated as only being .equals() if its the same object.

    If you want to compare the contents you have to use Arrays.equals(a, b)

    BTW: Its not the way I would design it. ;)

提交回复
热议问题