码迷,mamicode.com
首页 > 其他好文 > 详细

方法重载

时间:2017-02-20 18:18:19      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:[]   size   dem   win   new   5.5   code   main   ack   

package com.qingfeng;
/**
 * 
 * @author win7
 *功能:方法重载 why how
 */
public class Demo3_7 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Ab a1= new Ab();
        System.out.println("a和b较大的是:"+a1.getMax(6,5));// 6,5  5.5,2.3
    }
}
class Ab{
    //返回两个int中较大的数
    public int getMax(int a, int b){ //getMax()
        if(a >= b)
            return a;
        return b;
    }
    //返回两个float较大的数
    public float getMax(float a, float b){//getMax()
        if(a >= b)
            return a;
        return b;
    }
}

 

方法重载

标签:[]   size   dem   win   new   5.5   code   main   ack   

原文地址:http://www.cnblogs.com/qingfengzhuimeng/p/6420544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!