• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please Explain this Constructor parameter type ?

 
lakmal padmakumara
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 !




 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rok Ć telcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Check following link for understanding:
http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html


Regards,
Rok
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... 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.
 
lakmal padmakumara
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thanks !!! You People are really helpful !! It helped me a lot !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic