Want to compare arrays of which item may not be in same order. Here is the solution:
public static boolean compareArrays(String[] actual, String[] expected)
{
if(actual == null || expected == null)
return false;
Arrays.sort(actual);
Arrays.sort(expected);
if(Arrays.equals(actual, expected))
return true;
else
return false;
}
No comments:
Post a Comment