因此,我正在編寫一個小程序,但我的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
我在我的代碼中修復一個錯誤的方式是使用我的調試器。我建議你逐步調試調試器中的代碼,看看它爲什麼在做它正在做的事情。 –