For example, I have two arrays:
String [] arr1 ={"You", "book"};
String [] arr2 ={"Do", "You", "like","book" };
I want to check if arr1
match the arr2
in terms of the same order. If arr1
is {"book", "You"}
, then arr1
does not match arr2
.
Alright, I think that my code is wrong, but anyway:
for (int i = 0; i<arr1.length; i++){
for (int j=0; j<arr2.length; j++){
if (arr1[i] != arr2[j]){
return null;
}
}
}
But when I run it, it always return null
even my arr1
does match arr2
.