저는 작은 프로그램을 작성하고 있지만 while 루프는 작동하지 않는 것으로 보입니다. 인터넷을 통해 자습서를 찾아 보았지만 J를 늘려야한다는 것을 알고 있습니다. 내가 한 가지를 고칠 때 다른 부분이 작동을 멈추는 이유를 알아내는 것 같습니다! 누군가이 문제를 해결하기 위해 무엇을해야 할 지 말해 줄 수 있습니까?자바 루프가 작동하지 않습니다.
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
내 코드에서 버그를 수정하는 방법은 디버거를 사용하는 것입니다. 내가하는 일을 왜하는지 디버거의 코드를 단계별로 살펴 보길 권한다. –