Compare Two byte Arrays in Java
Description
The following code shows how to compare Two byte Arrays.
Example
/*ww w . j a v a 2 s. c o m*/
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
byte[] a1 = new byte[] { 7, 25, 12 };
byte[] a2 = new byte[] { 7, 25, 12 };
System.out.println(Arrays.equals(a1, a2));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »