Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initializing array through constructor

 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Now though we popularly know that we cannot initialize the array reference by passing the values in constructor,like:


I was thinking what was the reason behind dis-allowing this method? Is there any alternate method? 'cause otherwise there is going to be
always an additional reference in main's stack frame pointing to the array object on heap... which is kind of not a good idea.
comments please.

regards
 
Vijay Tidake
Ranch Hand
Posts: 148
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
TestArray t=new TestArray({10,20,30,40,50});


This is like The constructor TestArray (int, int, int, int, int) .




 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or make it a varags parameter
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thanks guys that was useful...Great!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic