I need to check if a string (word, no whitespaces) has any letters of a given alphabet.
String A: apple
String B: bed
Alphabet: a b c d e f
I want to compare efficiently the string with the alphabet. What I want is to check if String consists of the letters in Alphabet. For now I have my alphabet in an ArrayList and in a for loop I check if String contains the letter of the arraylist and if true then exit, else continue with the next letter. The example above for String A will return false because p and l are not part of the alphabet. But it will return true for B.
Can this be done more efficiently? Thank you for your help.