JAVA

JAVA,第1张

public class Method_Demo_2 {
    public static void main(String[] args) {
        Count12 c2=new Count12();
        //求两个整数的最大值
        System.out.println(c2.max(9,7));
        //求一个整数的最大值
        System.out.println(c2.max(9,11,3));
        //求最小数的最大值
        System.out.println(c2.max(9.3,9.5));
    }
}
class Count12{
    public int max(int i,int j){
        //i=9,j=7
        return i>j? i : j;
    }
    public int max(int q,int w,int e){
        //q=9,w=11,e=3
        return max(max(q,w),e);
    }
    public double max(double a,double b){
        //a=9.3 ,b=9.5
        return a>b? a:b;
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/3002194.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-27
下一篇 2022-09-27

发表评论

登录后才能评论

评论列表(0条)

保存