import java.util.*;
class Program {
public static void main
(String[] args
) { Scanner ent
= new Scanner
(System.
in); System.
out.
println("Digite a palavra/frase:"); // crio as strings
// verifico se têm o mesmo tamanho
if (isAnagram
(s, r
)) System.
out.
println("É anagrama"); }
//se as duas strings não tem o mesmo tamanho, não é anagrama
if ( s1.length() != s2.length() ) return false;
//tranfroma em arrays para poder ordenar
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
//ordena para garantir a comparação simplificada
//cria as novas strings baseadas nos arrays ordenados
return sc1.equals(sc2);
}
}
//https://pt.stackoverflow.com/q/42319/101
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgUHJvZ3JhbSB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBlbnQgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRGlnaXRlIGEgcGFsYXZyYS9mcmFzZToiKTsKICAgICAgICAvLyBjcmlvIGFzIHN0cmluZ3MKICAgICAgICBTdHJpbmcgcyA9IGVudC5uZXh0TGluZSgpOwogICAgICAgIFN0cmluZyByID0gZW50Lm5leHRMaW5lKCk7CiAgICAgICAgLy8gdmVyaWZpY28gc2UgdMOqbSBvIG1lc21vIHRhbWFuaG8KICAgICAgICBpZiAoaXNBbmFncmFtKHMsIHIpKSBTeXN0ZW0ub3V0LnByaW50bG4oIsOJIGFuYWdyYW1hIik7CiAgICB9CiAgCiAgICBwdWJsaWMgc3RhdGljIGJvb2xlYW4gaXNBbmFncmFtKFN0cmluZyBzMSwgU3RyaW5nIHMyKSB7CiAgICAgICAgLy9zZSBhcyBkdWFzIHN0cmluZ3MgbsOjbyB0ZW0gbyBtZXNtbyB0YW1hbmhvLCBuw6NvIMOpIGFuYWdyYW1hCiAgICAgICAgaWYgKCBzMS5sZW5ndGgoKSAhPSBzMi5sZW5ndGgoKSApIHJldHVybiB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