黑马程序员技术交流社区
标题:
this关键字-调用本类的构造方法
[打印本页]
作者:
无云
时间:
2015-9-2 00:30
标题:
this关键字-调用本类的构造方法
public class Demo2 {
public String name;
public String age;
Demo2(){
this("ccc","ddd");
}
Demo2(String name,String age){
this.name=name;
this.age=age;
System.out.println(this.name);
System.out.println(this.age);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Demo2 d=new Demo2();
System.out.println(d);
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2