核心

Arrays.equals

代码块

  1. import java.util.*;
  2. public class CheckArrayEquality {
  3. public static void main(String[] args) throws Exception {
  4. int[] ary = { 1, 2, 3, 4, 5, 6 };
  5. int[] ary1 = { 1, 2, 3, 4, 5, 6 };
  6. int[] ary2 = { 1, 2, 3, 4 };
  7. System.out.println("Is array 1 equal to array 2?? "
  8. + Arrays.equals(ary, ary1));
  9. System.out.println("Is array 1 equal to array 3?? "
  10. + Arrays.equals(ary, ary2));
  11. }
  12. }