I need to buy two strings and check if the second is an anagram of the first. I thought about using FOR loop repetition. I think you should first check if they both have the same size, then go through them and check if each letter of the first one also exists in the second. If they all exist, one is the anagram of the other. I just do not know how to do this ...
public static void main(String[] args) {
Scanner ent = new Scanner(System.in);
String s, r;
int i, j;
System.out.println("Digite a palavra/frase:");
// crio as strings
s = ent.nextLine();
r = ent.nextLine();
// verifico se têm o mesmo tamanho
if (s.length()==r.length()) {
// percorro ambas verificando se cada letra da 1ª existe na 2ª
for (i=0; i<s.length(); i++) {
for (j=0; j<r.length(); j++) {
// não sei continuar...
}
}
}
}