1、构造方法

public class AnyThing {
    
    public AnyThing(){                              //定义无参构造方法
           this("this 调用有参构造方法");          //使用this关键字调用有参构造方法
    
    System.out.println("无参构造方法");
}
    public AnyThing(String name){                  //定义有参构造方法
        
        System.out.println("有参构造方法");
        
    }
}

 

posted on 2016-01-18 08:27  悠悠小花  阅读(133)  评论(0编辑  收藏  举报