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 }

 

posted @ 2013-03-28 10:00  glt66  阅读(140)  评论(0编辑  收藏  举报