Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Variable Length Parameters in Java
public class VariableLengthParameters {
private static int maximum(int first, int... additional) {
int max = first;
for (int i = 0; i < additional.length; i++)
if (additional[i] > max)
max = additional[i];
return max;
public static void main(String[] args) {
int max = maximum(10, 4, 55, -3, 454, 23, 66);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.