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

4.方法重载

时间:2016-05-27 23:45:07      阅读:460      评论:0      收藏:0      [点我收藏+]

标签:

package structMehtod;

public class Calc {
    public int getSum(int num1,int num2){
        System.out.println("int");
        return num1+num2;
    }
    
    public double getSum(double num1,double num2){
        System.out.println("double");
        return num1+num2;
    }
    
    public double getSum(double num1,double num2,double num3){
        return num1+num2+num3;
    }
    
    public static void main(String[] args) {
        Calc calc=new Calc();
        System.out.println(calc.getSum(67, 89));
        System.out.println(calc.getSum(67, 89,78.4));
    }
}

 

4.方法重载

标签:

原文地址:http://www.cnblogs.com/xiaotaoxu/p/5536405.html

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