steven
2009-02-13 17:00:18 UTC
public boolean isValidPrefix(String prefixToCheck)
{
if ((java.util.Arrays.binarySearch(dictionary, prefixToCheck))>=0)
{
return true;
}
return false;
}
I’m wondering why the return of this binary search is -65537, I was expecting to be a positive number since the String prefixToCheck test is in the dictionary array I created. the dictionary is like this:
gyve
gyved
gyves
gyving
ha
haaf
haafs
haar
haars
habanera
habaneras
habdalah
habdalahs
haberdasher
haberdasheries
haberdashers
I wonder if that method only works if it needs the whole word to work
if it is just a string "h" will it work? and return a positive number?
i think so, but what do you think?
Any help would be appreciated, thanks.