package test; public class myTest { // 根据输入的参数动态生成数组 public static int max(int... param) { int max = 0; int length = param.length; for (int i = 0; i < length; i++) { if (max < param[i]) { max = param[i]; } } return max; } public static void main(String[] args) { int test1 = max(1, 2, 3, 5); int test2 = max(0, 6, 3, 6, 9, 7); System.out.println("test1=" + test1 + " test2=" + test2); } } --------------------- 本文来自 chance_66 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/never_tears/article/details/78027823?utm_source=copy