this question has answer here:
- java, 3 dots in parameters 9 answers
i looking @ java code , saw use of ...
, thought replacement of []
here example using ...
:
public studentdata(string firstname,string lastname,double ... list) { // initialise instance variables this.firstname = firstname; this.lastname = lastname; this.testscores = testscores; this.grade = grade; grade = coursegrade(list); //calc }
here example without it:
public studentdata(string firstname,string lastname,double [] list) { // initialise instance variables this.firstname = firstname; this.lastname = lastname; this.testscores = testscores; this.grade = grade; grade = coursegrade(list); //calc }
i tried using in code , solved few of error messages lingering. can explain functionality of ...
vs. []
the difference between
public studentdata(string firstname,string lastname,double ... list)
and
public studentdata(string firstname,string lastname,double [] list)
is in latter, caller has instantiate array , give argument. in former, arguments automatically put array. called varargs.