package liu0919;public class ChongZai {public int max(int a, int b) {return a >= b ? a : b;}//参数个数相同,数据类型不相同,不冲突public double max(double a, double b) {return a >= b ? a : b;}//参数个数不同,数据类型相同,不冲突public double max(double a, double b, double c) {return max(max(a, b), c);}}
package liu0919;public class Ceshi_chongzai {public static void main(String[] args) {ChongZai cz=new ChongZai ();System.out.println("58和12大的数是:"+cz.max(58, 12));System.out.println("58.12和12.24大的数是:"+cz.max(58.12, 12.24));System.out.println("18.1与25.5和30.0比较大的是:"+cz.max(18.1, 25.5, 30.0));}}