I need a Method that takes all the characters of a String and checks if those characters are in another String.
The Method I have:
public boolean isItemUsable2(String word1, String word2) {
int count = 0;
for (int i = 0; i < word2.length(); i++) {
String itemPiece = Character.toString(word2.charAt(i));
if (word1.contains(itemPiece)) {
count++;
}
}
return count == word2.length();
}
The problem is, for example word 1 is "12345++" and word 2 is "155" it should say it's false since there is only one 5, but it shows true and I don't know how to fix it.