how to compare the Java Byte[] array?

后端 未结 15 2371
囚心锁ツ
囚心锁ツ 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 01:57

    Use Arrays.equals() if you want to compare the actual content of arrays that contain primitive types values (like byte).

    System.out.println(Arrays.equals(aa, bb));
    

    Use Arrays.deepEquals for comparison of arrays that contain objects.

提交回复
热议问题