Created
January 21, 2020 00:24
-
-
Save kubilaycicek/1db6590d14ba8b5514eb9637016223af to your computer and use it in GitHub Desktop.
Variable Arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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