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

array initialization?

 
harish shankarnarayan
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example by Barry Sir,

this compiles fine can anyone explain me wat all r the possible ways we can initialize.

as per wat i knew , ifelt only thru " new " i can initialize arrays.
as per the example given above ,it it so trhat we can initialize arrays directly in the constructors as given above.
[ October 18, 2005: Message edited by: Barry Gaunt ]
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI..


int scores[]=new int[]{1,2};

or

int scores[]={1,2};


or

int scores[]=new int[2];

scores[0]=1;
scores[1]=2;


[ October 21, 2005: Message edited by: A Kumar ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"as per wat i knew , i felt... "

Yes, but what does your Java book say?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic