Compare Two Array Program – Java

- Advertisement -

 

- Advertisement -

package JavaPrograms;

public class CompareArray {

public static void compareArrays(int[] array1, int[] array2) {
boolean b = true;
if (array1 != null && array2 != null){
if (array1.length != array2.length)
b = false;
else
for (int i = 0; i < array2.length; i++) {
if (array2[i] != array1[i]) {
b = false; 
} 
}
}else{
b = false;
}
System.out.println(b);
}
}


Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More