我不认为我对为什么 -1 在这段代码中起作用有一个明确的理解:它只是一个允许程序继续运行的位置标记吗?任何帮助或指导将不胜感激。
public class RemovingChar {
public static void main(String[]args)
{
String str = "Looking out the window of my small apartment";
String remove = "aeiou";
String x = " ";
for(int i=0; i<str.length(); i++)
{
char c = str.charAt(i);
if(remove.indexOf(c) == -1)
{
x+= c;
}
}
System.out.print(x);
}
}