| Author |
Why does this method call compile with only one argument ?
|
Harry Henriques
Ranch Hand
Joined: Jun 17, 2009
Posts: 206
|
|
|
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
Because String... is a var-arg which is a convenience for passing an array.
So if you do
The compiler will turn it into
which is a valid String array.
If you omit this argument completely as in your example, the compiler does this:
Which is a 0 sized String array and perfectly legal.
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
Salil Vverma
Ranch Hand
Joined: Sep 06, 2009
Posts: 219
|
|
Hey Harry,
... operator represents 0 or more arguments . In this case the function can be called in various formats.. I believe, the below code would clear your doubt.
The output would be
The array elements are -
21 22
The array elements are -
20 30 40
The array elements are -
1 2 3 4
The array elements are -
|
Regards
Salil Verma
|
 |
 |
|
|
subject: Why does this method call compile with only one argument ?
|
|
|