Skip to content

Instantly share code, notes, and snippets.

@kubilaycicek
Created January 21, 2020 00:24
Show Gist options
  • Save kubilaycicek/1db6590d14ba8b5514eb9637016223af to your computer and use it in GitHub Desktop.
Save kubilaycicek/1db6590d14ba8b5514eb9637016223af to your computer and use it in GitHub Desktop.
Variable Arguments
package com.company;
public class Main {
public static void main(String[] args) {
Test test = new Test();
test.varArgs(0);
test.varArgs(0,1);
test.varArgs(0,1,2);
test.varArgs(0,1,2,3);
test.varArgs(0,1,2,3,4);
}
}
class Test {
public void varArgs(int... number) {
for (int i : number) {
System.out.println(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment