How to check whether two arrays are equal or not in Java

1 Answer

0 votes
import java.util.Arrays;

public class MyClass {
    public static void main(String args[]) {
        int[] arr1 = new int [] {1, 2, 3, 4, 5}; 
        int[] arr2 = new int [] {1, 2, 3, 4, 5}; 

        System.out.println(Arrays.equals(arr1, arr2)); 
    }
}


/*
run:

true

*/

 



answered Oct 4, 2019 by avibootz

Related questions

1 answer 171 views
3 answers 258 views
1 answer 124 views
...