java方法重载

class Tree{
    Tree(){
        System.out.print("默认构造器\n");
    }
    Tree(int i){
        System.out.print("重载构造器\n");
    }
    void info(){
        System.out.print("默认方法\n");
    }
    void info(int k){
        System.out.print("重载方法\n");
    }
}
public class Overloading {
    public static void main(String[] args){
        Tree te=new Tree(3);
        te.info();        
    }
}

根据参数列表区分调用的构造器和方法

posted @ 2013-03-08 10:45  玉伽  阅读(125)  评论(0编辑  收藏  举报