Advertisement
FatHsun

Untitled

Aug 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.55 KB | None | 0 0
  1. public static boolean equals(Object[] a, Object[] a2) {
  2.     if (a==a2)
  3.         return true;
  4.    
  5. // I thought it's false, maybe we can change it as the comment below
  6. if (a==null || a2==null)
  7.         return false;
  8. /*
  9. if (a==null && a2==null)
  10.         return true;   
  11. */
  12.     int length = a.length;
  13.     if (a2.length != length)
  14.         return false;
  15.  
  16.     for (int i=0; i<length; i++) {
  17.         Object o1 = a[i];
  18.         Object o2 = a2[i];
  19.         if (!(o1==null ? o2==null : o1.equals(o2)))
  20.             return false;
  21.     }
  22.  
  23.     return true;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement