因此,我正在编写一个小程序,但我的while循环似乎不工作,我看遍了互联网的教程,我知道我需要增加J,但我不能似乎弄清楚在哪里,因为当我得到一件事固定另一部分停止工作! 有人能告诉我我需要做什么来解决这个问题吗?Java循环不工作
int j=0;//which group we're checking
while(response==0){
{
if(inArray(quote.toLowerCase(),greetings[j*2]))
{
response=2;
int r=(int)Math.floor(Math.random()*greetings[(j*2)+1].length);
addText("\n-->Miku:\t"+greetings[(j*2)+1][r]);
try (BufferedReader br = new BufferedReader(new FileReader("mikuname.txt"))) {
String name;
while ((name = br.readLine()) != null) {
addText(name +"!");
}
} catch (IOException e1) {
// Do something with the IO problem that occurred while reading the file
}
}
}
if(response==0)
{
if(inArray(quote.toLowerCase(),chatBot[j*2]))
{
response=2;
int r=(int)Math.floor(Math.random()*chatBot[(j*2)+1].length);
addText("\n-->Miku:\t"+chatBot[(j*2)+1][r]);
}
}
if(response==0)
{
response=1;
}
}
为什么你在'while'之后有两个'{'? – Maroun
你打算用这个while循环完成什么? – Mike
我在我的代码中修复一个错误的方式是使用我的调试器。我建议你逐步调试调试器中的代码,看看它为什么在做它正在做的事情。 –