I´m a bloody beginner trying to write a lil programm to check if 2 words are anagrams. So far all the whitespaces within the words get deleted but apparently there's an error with my Arrays.sort() but I can´t see it. Why and where´s the error in my Arrays.sort() line and how could I solve it?
Edit: If I leave the Arrays.sort() out like this it compiles and works so apparently there's only a problem with that line. If I leave them in it points to array and says error: can not find symbol
public static void isAnagramm(String wordOne, String wordTwo)
{
String w1= wordOne.replaceAll("\\s", "");
int word1 = w1.length();
String w2 = wordTwo.replaceAll("\\s", "");
int word2 = w2.length();
boolean anagrammStatus = false;
if(word1 == word2)
{
anagrammStatus = true;
}
else
{
char [] charArrayWordOne = w1.toLowerCase().toCharArray();
char [] charArrayWordTwo = w2.toLowerCase().toCharArray();
//Arrays.sort(charArrayWordOne);
//Arrays.sort(charArrayWordTwo);
anagrammStatus = charArrayWordOne.equals(charArrayWordTwo);
}
if(anagrammStatus == false)
{
System.out.println("Anagram");
}
else;
{
System.out.println("No Anagram");
}
}