44
Question Question 38
Write a function that checks whether or not two arrays (of characters) are identical, that is, whether they have same characters and all characters in corresponding positions are equal.
public class KboatArrCompare
{
public void arrCompare (char A[], char B[])
{
int l1 = A.length;
int l2 = B.length;
boolean flag = true;
if (l1 == l2) {
for(int i = 0; i < l1; i++) {
if(A[i] != B[i]) {
flag = false;
break;
}
}
}
else {
flag = false;
}
if (flag) {
System.out.println("Arrays are equal");
}
else {
System.out.println("Arrays are not equal");
}
}
}Output



