繁体   English   中英

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

[英]Type mismatch: cannot convert from int to boolean in while loop

我刚开始学习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();

大概i是一个int ,而不是boolean 与C / C ++不同,它不会隐式转换为boolean 您必须将条件明确声明为boolean

while (i < arraycomment.length) // or some other constant

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM