重载

    xiaoxiao2023-11-15  144

    package atwanyi.exer; public class OverloadExer { //1.如下的三个方法构成重载 public void moL(int i) { System.out.println(i * i); } public void moL(int i,int j) { System.out.println(i * j); } public void moL(String s) { System.out.println(s); } //2.如下的三个方法构成重载 public int max(int i,int j) { return(i > j)? i : j; } public double max(double d1,double d2) { return(d1 > d2)? d1 : d2; } public double max(double d1,double d2,double d3) { double max = (d1 > d2)? d1 : d2; return (max > d3)? max : d3; } }
    最新回复(0)