Skip to content

Commit e3458d9

Browse files
committed
Example of Variable Length Arugments
1 parent c554346 commit e3458d9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/Functions/VarArgs.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package Functions;
2+
3+
import java.util.Arrays;
4+
5+
public class VarArgs {
6+
public static void main(String[] args) {
7+
8+
function(10, 20, 30, 40);
9+
multipleArguments(10, 20, "Pradeep", "SriTalli", "Sahithi", "Nandhan");
10+
}
11+
12+
/*Variable length Argument should always be at the last*/
13+
static void multipleArguments(int a, int b, String...v){
14+
System.out.println(Arrays.toString(v));
15+
}
16+
17+
static void function(int...v){
18+
System.out.println(Arrays.toString(v));
19+
}
20+
}

0 commit comments

Comments
 (0)