java重载,非静态方法的调用

//方法的重载是指在一个类中可以定义相同的名字。但参数不同的多个方法。调用时,会根据不同的参数表选择对应的方法。

public class Test {
	void max (int  a , int b) {
		System.out.println( a > b ? a : b); 
	}
	
	
	void max(short a ,short b ) {
		System.out.println("short");
		System.out.println( a > b ? a : b);
	}
	
	
	

		
		
	void max(float a , float b) {
		System.out.println( a > b ? a : b); 
	}
	
	public static void main(String[] args) {
		Test t = new Test();
		t.max(3,4);
		short a = 3;
		short b = 4;
		t.max(a, b); 
	}
	
	
}

 

 


 

posted @ 2019-07-22 17:24  水果、、  阅读(365)  评论(0编辑  收藏  举报