java方法重载
1 //方法重载,max int short float 2 class Test 3 { 4 void max(int a, int b) 5 { 6 System.out.println(a>b?a:b); 7 } 8 void max(short a, short b) 9 { 10 System.out.println(a>b?a:b); 11 } 12 void max(float a, float b) 13 { 14 System.out.println(a>b?a:b); 15 } 16 17 public static void main(String[] args) 18 { 19 Test test=new Test(); 20 test.max(3, 4); 21 test.max(5.1f, 3.1f); 22 23 } 24 25 }