Skip to content

Instantly share code, notes, and snippets.

@bytecodeman
Created September 26, 2018 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytecodeman/87873214f194c548ad460861079860b6 to your computer and use it in GitHub Desktop.
Save bytecodeman/87873214f194c548ad460861079860b6 to your computer and use it in GitHub Desktop.
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);
System.out.println(max);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment