类型不匹配:在while循环中无法从int转换为boolean

use*_*537 1 java boolean

我刚开始学习java,试图找到答案,但我想我不够聪明.我正在尝试编写一个数组,我从一些文件到另一个文件.

问题是当我试图制作"while"时,它说不能从int转换为boolean.谁能提出一些建议.先感谢您.这就是我所拥有的:

public void savethefile() throws IOException{

File file1= new File("lala.ppm");
FileWriter save=new FileWriter(file1);
save.write(tytul);

while(i){
    save.write(arraycomment[i]);
    i++;
}

save.close();
Run Code Online (Sandbox Code Playgroud)

rge*_*man 6

大概i是一个int,而不是一个boolean.与C/C++不同,它不会被boolean隐式转换为.您必须明确说明您的情况boolean.

while (i < arraycomment.length) // or some other constant
Run Code Online (Sandbox Code Playgroud)