| Author |
Please Explain this Constructor parameter type ?
|
lakmal padmakumara
Ranch Hand
Joined: Aug 08, 2009
Posts: 47
|
|
what is the meaning of this 3 dots ? This is a code which is related to my assignment .I'm trying to understand this !
Can we have this kind of parameters in the method also ?
what i noticed here was when I can call this constructor
DelaunayPoint d1=new DelaunayPoint (3,4,5);
or
DelaunayPoint d1=new DelaunayPoint (3,4);
So this 3 dots means you can send any number of arguments below 3 ? Is that so ?Confused ! Please Help Thanks !
|
[Bsc in Computer Science and Engineering] [SCJP 80%][BCS certificate level]
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3673
|
|
lakmal padmakumara wrote:
what is the meaning of this 3 dots ?
That denotes var-args, you can send any number of arguments to that method/constructor which matches the type of the argument defined.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
Rok Ć telcer
Ranch Hand
Joined: Nov 03, 2009
Posts: 101
|
|
Hi,
Check following link for understanding:
http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html
Regards,
Rok
|
SCJP, SCWCD
|
 |
Salil Vverma
Ranch Hand
Joined: Sep 06, 2009
Posts: 219
|
|
... represents var-args operator. You can pass as many multiple values of the same type as you want or array of the same type. Kindly refer the below example for better understanding
The out put of the above code would be -1 2 3 4 35
I hope, this would clear all your doubts.
|
Regards
Salil Verma
|
 |
lakmal padmakumara
Ranch Hand
Joined: Aug 08, 2009
Posts: 47
|
|
|
Hey Thanks !!! You People are really helpful !! It helped me a lot !!!
|
 |
 |
|
|
subject: Please Explain this Constructor parameter type ?
|
|
|