package day16; public class Method_Demo02 { public static void main(String[] args) { //求两个整数的最大值 Count01 c1 = new Count01(); System. out. println(c1.max( 9, 7)); //求三个整数的最大值 System. out. println(c1.max( 9, 7,48)); //求小数的最大值 System. out. println(c1.max(5.5, 2.3)); } } // 2 usages class Count01 { // 1 usage public int max(int a, int b){ //a=6,b=7 return a>b? a : b; } public int max(int x, int y, int z) { // x =9 , y = 7, z = 5 return max(max(x,y),z); } public double max(double i, double j){ return i > j ? i : j ; } }
java:求小数的最大值
于 2022-09-26 09:30:03 首次发布