For a program I'm writing, I'm trying to get rid of doubles in my string (which is a concatenation of a keyword and the alphabet). My code was compiling fine until I added the code about concatenating the substrings before and after the character I'm trying to get rid of.
for (int i = 0; i < fullcrypt.length(); i++) {
System.out.println("i = " + i);
System.out.println(fullcrypt.charAt(i));
for (int j = i+1; j <= fullcrypt.length(); j++) {
System.out.println("j = " + j);
System.out.println(fullcrypt.charAt(j));
//if characters match, recreate string with substrings before and after matching character
if ((fullcrypt.charAt(i)) == (fullcrypt.charAt(j)) && j != fullcrypt.length)
fullcrypt = (fullcrypt.substring(0, j) + fullcrypt.substring(j+1));
else if (fullcrypt.charAt(i) == fullcrypt.charAt(j))
fullcrypt = (fullcrypt.substring(0,j));
}
}
At that point, there are a number of compilation errors demanding a class, interface, or enum for a bunch of things which don't make sense afterwards (ex: for a string, an if statement, etc.), so I'm pretty sure the problem is here, but I'm not sure where.
Thanks!