java重载

public class overLaod {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		print p1 = new print();
		print p2 = new print("ads");
		print p3 = new print("ads",555);
		
		p1.print();
		p1.print("p1");
		p1.print("p1",1);
		
		p2.print();
		p2.print("p2");
		p2.print("p2",2);
	}

}
class print {
	public print() {
		System.out.println("无参构造函数");
	}
	public print(String str) {
		System.out.println("字符串"+str);
	}
	public print(int num) {
		System.out.println("整型"+num);
	}
	public print(String str,int num) {
		System.out.println("字符串"+str+",整型"+num);
	}
	
	public void print() {
		System.out.println("没有返回值");
	}
	public void print(String con) {
		System.out.println(con);
	}
	public void print(String con,int num) {
		System.out.println(con+" "+num);
	}
	
}

 

posted @ 2018-02-05 20:15  biubiubiuo  阅读(75)  评论(0编辑  收藏  举报