this调用构造方法那必须放在构造方法中的第一条语句
2014-01-09 16:32
330 查看
public class ThisQuoteTest { String name; int age; String work; public ThisQuoteTest() { this("Lily",23,"teacher"); } public ThisQuoteTest(String name,int age,String work) { this.name =name; this.age=age; this.work=work; } public ThisQuoteTest(String name,int age) { this.name =name; this.age=age; } public static void main(String args[]) { ThisQuoteTest test=new ThisQuoteTest(); System.out.println("My name is "+test.name+"I am "+test.age+"My work is "+test.work); } }
相关文章推荐
- 如果构造方法中包含super(…)或this(…)调用,那么它们只能作为该构造方法的第一条语句,也就是说连try…catch都不可以有
- static方法不能直接访问类内的非static变量和不能调用this,super语句分析
- this调用本类方法(基本 /构造)
- JavaSE8基础 通过this()去调用本类的其他构造方法
- java中this.的使用;什么是构造方法,及构造方法的作用
- 使用this调用构造方法
- 在自定义控件的过程中犯下的错,在调用有三个参数的构造方法时this(context,null,0);第二个参数为空,在Activity中 findViewById找到对应的控件时
- 为什么java的构造方法中this()或者super()要放在第一行
- (教学思路 C#之类四)构造方法(静态构造方法、this、方法重载)、析构方法(修改新增)
- JAVA_SE基础——32.this关键字调用本类的构造方法
- (教学思路 C#之类四)构造方法(静态构造方法、this、方法重载)、析构方法(修改新增)
- 面向对象----构造方法、this 关键字、函数的参数传递、package语句/import语句
- [Java] this 调用重载构造方法
- 用this调用构造方法
- Java之Object构造方法(创建子类对父类构造方法的调用)
- Java中构造方法调用另一个构造方法
- 构造方法与普通方法的区别:构造方法在定义时就执行,而普通方法下必须调用才执行
- 黑马程序员--03.面向对象--04.子类构造必须访问父类构造的原因 this_super语句的含义【个人总结】
- 为什么java的子类中必须调用父类的构造方法
- Atitit. 构造ast 语法树的总结attilax oao 1. Ast结构树形12. ast view (自是个160k的jar )22.1. 多条语句ast结构22.2. 变量定义 int b,c; 的ast结构22.3. 方法调用meth1(a=1,b=2,c=3); 的ast结构23. 误解的问题33.1. 语法书子能是个二叉树,实际上多叉树越好..33.2. 非要不个ast放到个s