mathutils.java
来自「基于netbeans的java桌面应用程序合集」· Java 代码 · 共 35 行
JAVA
35 行
package com.sun.tiger.vararg;
public class MathUtils {
public static int max(int... values) {
if (values.length == 0) {
throw new IllegalArgumentException("No values supplied.");
}
int max = Integer.MIN_VALUE;
for (int i : values) {
if (i > max)
max = i;
}
return max;
}
public static void main(String[] args) {
int max;
// int max = max(1,2,3,4,5,6,7,8);
// int max = max(new int[]{2,4,6,8});
max = max();
// System.out.println(max);
//
// max = max(2,4,6,8);
// System.out.println(max);
//
// max = max(0);
// System.out.println(max);
//
// max = max();
System.out.println(max);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?