Check to see if the array arr1 contain the same elements as arr2 in the same order in java.
for example:
isTheSame({"1", "2", "3"}, {"1", "2", "3"}) → true
isTheSame({"1", "2", "3"}, {"2", "1", "1"}) → false
isTheSame({"1", "2", "3"}, {"3", "1", "2"}) → false
so far i have
public boolean isTheSame(String[] arr1, String[] arr2)
{
if (arr1.length == arr2.length)
{
for (int i = 0; i < arr1.length; i++)
{
if (arr1[i] == arr2[i])
{
return true;
}
}
}
return false;
}
The problem with this is that it only compares the first element of the two arrays.