有人可以向我解释下面的标记线是如何工作的吗?他们具体做什么?
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();
}
}