static 非法向前引用
2012-12-06 22:12
113 查看
public class ErrorDef2Test { static int num2 = 20; //下面代码将提示: 非法向前引用 static int num1 = num2 + 2; //static int num2 = 20; public static void main(String[] args) { System.out.println("第1个数" + num1); System.out.println("第2个数" + num2); } } public class RightDef { //下面代码将完全正常 int num1 = num2 + 2; static int num2 = 20; public static void main(String[] args) { RightDef obj=new RightDef(); System.out.println("第1个数" + obj.num1); System.out.println("第2个数" + num2); } } /* 第1个数22 第2个数20 请按任意键继续. . . */
相关文章推荐
- java 中的 成员变量、局部变量、静态变量、类变量、非静态变量、实例变量、向前引用、非法向前引用、静态代码块、非静态代码块 执行时机
- wpf staticresource 是不允许向前引用(forward reference)的
- java 中的 成员变量、局部变量、静态变量、类变量、非静态变量、实例变量、向前引用、非法向前引用、静态代码块、非静态代码块 执行时机
- java 中的 成员变量、局部变量、静态变量、类变量、非静态变量、实例变量、向前引用、非法向前引用、静态代码块、非静态代码块 执行时机
- java 中的 成员变量、局部变量、静态变量、类变量、非静态变量、实例变量、向前引用、非法向前引用、静态代码块、非静态代码块 执行时机
- java 中的 成员变量、局部变量、静态变量、类变量、非静态变量、实例变量、向前引用、非法向前引用、静态代码块、非静态代码块 执行时机
- Java中static变量相互引用导致的Bug
- QT引用OpenCV出现错误:warpers_inl.hpp:146: error: C2589: “(”:“::”右边的非法标记
- 为什么不允许从enum的构造函数中引用static变量?
- java 正则(4) 不常用 / 贪婪匹配 / 非捕获组 / 向前引用 / flag 简写
- java 中的向前引用
- 指针,static,const,引用,violate等等
- flex 3 list控件添加Item的方法【1061: 调用可能未定义的方法 addItem (通过 static 类型 spark.components:List 引用)】
- PHP static引用的作用域
- Java向前引用容易出错的地方
- c++-成员初始化问题(static, const, 引用)
- django引用static目录下的css,js文件304问题
- C++0x的三个特性:右值引用,static_assert,auto
- 向前引用 ? float VS long ? 这些知识你懂吗?
- error C2597: 对非静态成员“CManager::m_moveSpeed”的非法引用