Last Updated: September 12, 2021
·
203
· Bruno Volpato

Return maximum or minimum value of an array

public int min(int... args) {
    int min = args[0];
    for (int i = 1; i < args.length; i++) {
        min = Integer.min(min, args[i]);
    }
    return min;
}

public int max(int... args) {
    int max = args[0];
    for (int i = 1; i < args.length; i++) {
        max = Integer.max(max, args[i]);
    }
    return max;
}