Given an array of Strings , check if they are anagrams are not
1

class anagrams: in Java, class names must begin with a capital letter.

2

You restrict yourself to ASCII. However, you could use a HashMap&lt;Character, Integer&gt;. Of course, it implies larger constant factor, yet it matches the linear time complexity of your implementation.

Summa summarum

I thought about this:

public static boolean areAnagrams(String word1, String word2) {
    if (word1.length() != word2.length()) {
        return false;
    }

    Map&lt;Character, Integer&gt; map = new HashMap&lt;&gt;();

    for (char c : word1.toCharArray()) {
        map.put(c, map.getOrDefault(c, 0) + 1);
    }

    for (char c : word2.toCharArray()) {
        int count = map.getOrDefault(c, 0) - 1;

        if (count &lt; 0) {
            return false;
        }

        map.put(c, count);
    }

    return true;
}


Hope that helps.