构造函数重载和this调用构造函数
摘要:
class test { public static void main(String[] args) { Dog dog=new Dog(); dog.printAgeCount(); }}class Dog{ int age=0; String name="alex"; Dog(int age){ this.age=age; System.out.println("age="+age); } Dog(String name){ System.out.println("name="+name); this.name=name; } 阅读全文
posted @ 2013-06-19 19:07 iyon 阅读(175) 评论(0) 推荐(0) 编辑