I wrote a method for checking whether two Strings are anagram or not. The method is returning true even if the words are not anagram. I don't see any bug in the code, any ideas how can I improve ? The method is as following,
public static boolean checkAnagram( String one, String two){
if ( one.length() != two.length() )
return false;
char[] letters = new char[128];
for ( char c: one.toCharArray()){
letters[c]++;
}
for( int j =0; j < two.length(); j++){
int c = (int) two.charAt(j);
if( --letters[c] < 0) return false;
}
return true;
}