This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
------------------------------------------------------------------ 1. int i[]=null; 2. Object obj2=i; 3. Object obj1[]=i; //Compile Time error ------------------------------------------------------------------- Object obj1=i; Here one thing you have to remember. In java arrays are objects.
at line 3 you are just assigning the reference of the integer array ie(i[]) to an object array. now i[] and obj1 both are pointing to same arry in the heap.
[ April 30, 2007: Message edited by: anil kumar ] [ April 30, 2007: Message edited by: anil kumar ]
neha kanwal
Greenhorn
Joined: Jan 30, 2007
Posts: 11
posted
0
My main concern is -- Since arrays are object in java, so I understand when we say
obj1=i;
but how can I assign i to obj2[] ?
Lets be more precise...Pls look at the following code
I dont know how you are compiling .I am getting compile time error:cannot convert form int[] to Ojbect[] [ April 30, 2007: Message edited by: raj malhotra ]