I'm new to programming and trying to use HashSet.contains() method to check for elements in one HashSet exist in another HashSet. I defined a boolean method, compareString, to check if all the elements in stringExpected exists in stringActual. For some reason, it always return 'FALSE', any ideas?
This is what I have:
String[] stringExpected {"a", "b", "c"};
String[] stringActual {"a", "b", "c"};
boolean compareString(StringI[] stringExpected, String[] stringActual)
{
HashSet sActual = new HashSet();
HashSet sExpected = new HashSet();
for (int i = 0; i < uris.length; ++i)
{
sExpected.add(stringExpected);
}
for (int i = 0; i < stringActual.length; ++i)
{
sActual.add(stringActual);
}
return sActual.contains(sExpected);
}
This is what I have:
String[] stringExpected {"a", "b", "c"};
String[] stringActual {"a", "b", "c"};
boolean compareString(StringI[] stringExpected, String[] stringActual)
{
HashSet sActual = new HashSet();
HashSet sExpected = new HashSet();
for (int i = 0; i < uris.length; ++i)
{
sExpected.add(stringExpected);
}
for (int i = 0; i < stringActual.length; ++i)
{
sActual.add(stringActual);
}
return sActual.contains(sExpected);
}