Comparing the contents of two different arrays

Question:
How to compare the contents of two different arrays?

Answer:
Use Arrays.equals(array1, array2)

Code:
import java.util.Arrays;
 
class CompareArrays {
   public static void main (String[] args) {
 
      int arr1[] = {1, 2, 3};
      int arr2[] = {1, 2, 3};
 
      if (Arrays.equals(arr1, arr2)){
         System.out.println("Array contents are the same");
      } else {
         System.out.println("Array contents are different");
      }
   }
}

Output:
$ java CompareArrays
Array contents are the same