title: Anagram java code
body: <p>Can someone explain to me how the marked lines below work? What do they do exactly? </p>
  
  <pre><code>public class GrammerUtils {         
  
      public static void main(String args[]) {
          System.out.print(isAnagram("teacher", "cheater"));    
      }
  
      public static boolean isAnagram(String word, String anagram) {
          if (word.length() != anagram.length()) {
              return false;
          }  
          char[] chars = word.toCharArray(); // marked
          for (char c: chars) {              // marked
              int index = anagram.indexOf(c);// marked
              if (index != -1) {             // marked
                  anagram = anagram.substring(0, index) + anagram.substring(index + 1, anagram.length());
              } else {
                  return false;
              }
          }
          return anagram.isEmpty();
      }
  }
  </code></pre>