成员变量在构造器之后
2015-05-04 15:35
218 查看
public class Super { public Super(){printThree();} //===2 public void printThree() { System.out.println("three"); } } public class Test extends Super { int three = (int)Math.PI; public void printThree() { System.out.println(three);//===3 three=0,成员变量在构造器之后 } public static void main(String[] args) { Test t = new Test(); //===1 t.printThree(); //===4 } }
结果是:
0
3
相关文章推荐
- java笔记之局部变量、成员变量和构造器
- java笔记之局部变量、成员变量和构造器
- java笔记之局部变量、成员变量和构造器
- 【java】编写一个学生类,提供name,age,gender,phone,address,email成员变量, * 且为每个成员变量提供setter、getter方法。为学生类提供默认的构造器和带
- 成员方法,成员变量,局部变量,构造方法,构造器
- java 父类子类成员变量,静态变量,构造器创建先后顺序
- 成员变量、构造器的运行顺序
- 关于Java的构造器和直接为成员变量赋值的区别
- 面向对象——类的成员之成员变量、构造器
- 【java】编写一个学生类,提供name,age,gender,phone,address,email成员变量, * 且为每个成员变量提供setter、getter方法。为学生类提供默认的构造器和带
- 第04天OC语言(13):自定义构造方法以及成员变量名称注意点
- Java中的成员变量和局部变量
- 黑马程序员——java语言加强部分——反射之成员变量和数组
- C++中成员变量的初始化操作(4)---《Effective C++》
- c/c++笔试题——const类型的成员函数内部如何改变成员变量
- 成员变量与局部变量、JavaDoc注释
- C++中的线程函数如何访问类中的成员变量
- 类成员变量中存在引用,const,和指针类型时需要注意的事项
- 指向对象成员变量的指针
- Objective-C类成员变量深度剖析