java错误i cannot be resolved求解这段代码出错:int sum = 0;for(int i = 0; i < 10; ++i){if(i == 5)break;if(i > 3)continue;sum += i;}System.out.println(i+sum);//这里显示i cannot be resolved 错误看懂了.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/14 23:23:34
java错误i cannot be resolved求解这段代码出错:int sum = 0;for(int i = 0; i < 10; ++i){if(i == 5)break;if(i > 3)continue;sum += i;}System.out.println(i+sum);//这里显示i cannot be resolved 错误看懂了.
java错误i cannot be resolved
求解这段代码出错:
int sum = 0;
for(int i = 0; i < 10; ++i)
{
if(i == 5)
break;
if(i > 3)
continue;
sum += i;
}
System.out.println(i+sum);//这里显示i cannot be resolved 错误
看懂了.
java错误i cannot be resolved求解这段代码出错:int sum = 0;for(int i = 0; i < 10; ++i){if(i == 5)break;if(i > 3)continue;sum += i;}System.out.println(i+sum);//这里显示i cannot be resolved 错误看懂了.
System.out.println(i+sum);这里的i是不能使用的,因为这个i是循环里定义的私有变量
如果想实现你的需求,你就要将i定义在外面如:
int sum=0;
int i=0;