Following is the required program for the above mentioned problem. The code has been compiled and run in Eclipse Oxygen and is a genuine piece of program.
The code BEGINS from here:
public class ArrayComp {
public static void main(String[] args) {
char[] arr1 = {‘H’, ‘E’, ‘L’, ‘L’, ‘O’}; // Array-1
char[] arr2 = {‘H’, ‘E’, ‘L’, ‘L’, ‘U’}; // Array-2
boolean match = true; // default value for match
// Loop to test the matching
for (int i = 0; i < 5; i++) {
if(arr1[i] != arr2[i]) {
match = false;
break;
}
}
if (match == true)
System.out.println(“Result = 1”);
else
System.out.println(“Result = 0”);
}
}
The code ENDS here!
Following is the screenshot of the output for the above code: