问题描述
我知道C和Java使用词法作用域,并且变量的范围在定义它的块内。 参见Java代码:
ALL ARTICLES FROM CATEGORY: {{ articlecategory.category_name | upper }}
该程序给出错误“方法main中已经定义了变量j”
请参见C中的代码:
public class Main
{
public static void main(String[] args) {
int j = 0;
while(j==0){
int j =1;
System.out.println(j);
}
}
}
在这里,我们得到一个无限循环“ 11111111 .........”作为输出。
为什么C编译器不像Java那样抱怨j变量?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)