Forums Register Login

confuse code

+Pie Number of slices to send: Send
int x = ( int ) ( Math.random()*5 );
String name = new String[] { "a","b","c","d","e" }[x];

I am not getting the second line please help ...
thanks a lot ...
+Pie Number of slices to send: Send
I hope u unserstood the first line.. it would return a random number from 0 - 4.
In the second line => new String[] { "a","b","c","d","e" }, is nothing but a string array it is equivalent to declaring an array and assinging it.
String[] arrayStrings = new String[] { "a","b","c","d","e" };
String name = arrayStrings[x];//this would assing the element corresponding to the random index..
+Pie Number of slices to send: Send
thanks jagadeesh ,
it is using anonymous array ... right ?

this line should be like this in your post , i think .


but , it was really cool ...
[ January 13, 2005: Message edited by: rathi ji ]
+Pie Number of slices to send: Send
and you think you can pass the SCJP exam?
you don't even comprehend basic programming concepts like arrays...
+Pie Number of slices to send: Send
 

Originally posted by Jeroen Wenting:
and you think you can pass the SCJP exam?
you don't even comprehend basic programming concepts like arrays...



Are you here to make insults of people ... why you are here ... you don't make any question ... You don't answer any question ( oh sorry , that require mind , so its just impossible for you ) ... I am sure out of your 3000 message 2900 are waste .... actually you are whole waste .... I am dam sure that you are very inferior , failure kind of person .... no body is happy with you ( even your wife ( if she is living with you till now ...) )
+Pie Number of slices to send: Send
i am completely agree with rathi ji . either moderator should throw out jeroen or he should leave this friendly community .
+Pie Number of slices to send: Send
s.. its an anonymous array.. i am not sure if u can not initialize an array with String[] s = new String[]{"a",..}.. it could be possible..plz check it by writing a small program..
+Pie Number of slices to send: Send
yaa jagadeesh ,
what happened to us .... its an anonymous array object so definately it is refered by a array reference .... it is valid ...
thanks a lot ....
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 763 times.
Similar Threads
Vector and Array please help
initialisation and reinitialisation doubt.....
convert int ,double to string
how to get reverse string
StringTokenizer not helping in splitting
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:53:32.