In an java interview I was asked that how would you code to compare Array elements with each other to find out how many elements or indexes are equals and How many elements are not equal? Is there a way I can compare Array values in Java without using a for or while loop? The first thing that came in my mind that Arrays class provides us utility methods equals()
and deepEquals()
, but at last I was not able to make up, please advise with a small example that how can I solve this problem?
int[] i1 = new int[] {1,2,3,4};
int[] i2 = new int[] {0,5,3,3};