Java anagram detection