I'm trying to write a boolean method that would return true if the word in the first string can be re-arranged to spell the word in the second string. So for example, ("basketball","soccer") would return false and ("basketball","baseball") would return true.
This what I got so far for my method.
public static boolean canSpell (String first, String second) {
boolean canspell = false;
if (first.contains(second)) {
canspell = true;
}
return canspell;
}
but contains seems to only work if the two strings are exactly the same.