题目内容
程序填空题:编写多个求最大值的方法,实现方法的重载。public class MethodDemo {public static void main(String[] args) {System.out.println("3与4最大值为:" + max(3, 4));System.out.println("3.0与5.7最大值为:" + max(3.0, 5.7));System.out.println("3.0,5.7与10.4最大值为:" + max(3.0, 5.7, 10.4));}public static int max(1) {if (num1 > num2) {return num1;} else {return num2;}}public static double max(2 ) {if (num1 > num2) {return num1;} else {return num2;}}public static double3 (double num1, double num2, double num3) {return max( 4, num3);}}
查看答案
搜索结果不匹配?点我反馈