I have a language dictionary (i.e. english,italian,etc...), that essentially is a file with one word on every line.
Now i want to create a class with a method that given a string in input check if that string exists into that dictionary.
My idea is that the method return a boolean value. In pseudocode:
boolean checkWord(String s){
if(StringIsInDictionary) return true;
return false
}
What should be the best way to implement that feature?
Consider that the file will contain ~65000 words.
解决方案
Read the dictionary into a Set (for example, HashSet), and then use set.contains(word).