Forums Register Login

array initialization?

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
"as per wat i knew , i felt... "

Yes, but what does your Java book say?
Men call me Jim. Women look past me to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 542 times.
Similar Threads
Array doubt
I am a real JAVA beginner, please take a look at this code.
Two dimensional array
local variable creation
ExamCram Qts
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:15:19.