_this的使用方法--------括号留空,传的是 无参数的构造函数
2012-03-16 18:26
225 查看
class Person{ String name; int age; String address; Person(){ System.out.println("无参数的构造函数"); } Person(String name, int age){ this.name = name; this.age = age; System.out.println("两个参数的构造函数") } Person(String name, int age, String address){ //括号留空,传的是 无参数的构造函数 this(name,age)括号里填了东西是两个参数的构造函数 this(); this.address = address; System.out.println("三个参数的构造函数"); } void talk(){ System.out.println(" my name is" + name); } }
相关文章推荐
- _this的使用方法--------括号留空,传的是 无参数的构造函数
- Lesson_for_java_day08--类的属性和方法、类的封装性、构造函数和this的使用
- Linux中大括号扩展参数的使用方法
- Linux中大括号扩展参数的使用方法
- 使用ASM获取java的构造函数参数名称和方法参数名称
- 使用this作为方法的参数
- 对Java方法内部使用this访问成员变量的深入理解
- shell中的各种括号的使用方法
- addEventListener里面的参数和具体的使用方法
- 构造函数中:this(…)的使用
- initWithFireDate 方法参数说明。典型的selector 与 id userinfo 使用示例
- 使用js获取地址栏参数的方法推荐(超级简单)
- 尽可能使用泛型方法,除非需要将类型参数用于实例的字段
- 定义构造函数时必须使用引用参数或指针参数
- ajax回调函数中使用$(this)取不到对象的解决方法
- exp/imp 参数设置与使用方法 (转载)
- unity学习——委托(带参数方法的使用)
- jquery Datatable参数及使用方法
- SpringMVC系列(五)使用 Serlvet 原生的 API 作为目标方法的参数