>"..." means that the method takes a variable number of arguments. You
>can pass zero, one, or many arguments in place of the "...", then
>iterate over the items passed in. It was a new feature of Java 5.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Hi Roedy,
I wrote function its prototype is "void nParameters(int... arguments)"
and when i tried below code then it gave me exception.
DriverControl driver = new DriverControl();
driver.nParameters(new int[1, 2, 3, 4, 5]);
Exception Statement:
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
The method nParameters(int...) in the type DriverControl is not
applicable for the arguments (int[], int, int, int, int)
Syntax error, insert "]" to complete Dimensions
Syntax error on token "]", delete this token
Its mean we can not pass array to N-parameter function pram.
Please refer me, some links to study N-Parameters in detail.
Regards,
-aimslife
Kevin Bagust - 25 Jul 2007 09:12 GMT
> I wrote function its prototype is "void nParameters(int... arguments)"
> and when i tried below code then it gave me exception.
>
> DriverControl driver = new DriverControl();
> driver.nParameters(new int[1, 2, 3, 4, 5]);
This line is wrong. It should be:
driver.nParameters(new int[]{ 1, 2, 3, 4, 5});
> Exception Statement:
> Exception in thread "main" java.lang.Error: Unresolved compilation
[quoted text clipped - 5 lines]
>
> Its mean we can not pass array to N-parameter function pram.
No. If you read the messages the compiler has decided to alter the
incorrect line (for some reason) to:
driver.nParameters(new int[1], 2, 3, 4, 5);
Which the compiler then complains that it cannot find the method.
Kevin Bagust.
AimsLife - 25 Jul 2007 09:37 GMT
Thanks! All!
Regards,
-aimslife
AimsLife - 25 Jul 2007 09:36 GMT
Hi Roedy,
> DriverControl driver = new DriverControl();
> driver.nParameters(new int[1, 2, 3, 4, 5]);
[quoted text clipped - 6 lines]
> Syntax error, insert "]" to complete Dimensions
> Syntax error on token "]", delete this token
I done it! I was passing array as a parameter in wrong way thats why
exception comes.
Code Correction:
DriverControl drive = new DriverControl();
drive.nParameters(new int[]{2, 5, 6, 8, 45});
we can pass array to N-Parameter argument. DriveControl is class has
main function.
Regards,
-aimslife