This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes References Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "References" Watch "References" New topic
Author

References

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Object objRef;
Object[] objArray = new Object [3];
int[] intArray = new int[10];
ObjRef = intArray ; //possible
objArray = intArray ; //not possible
Why?
Gopinath Rajgopal
Ranch Hand

Joined: Jun 26, 2000
Posts: 31
Hi,
This is a case of assigning a value to the array reference. For an array to be equated to another array, every element in it should be convertible to the other array type. Here, it is int to Object which is not possibe. objArray is an array of Object references. Hence the following will work:
objArray[0] = intArray ;
Hope this helped.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks Gopinath Rajgopal.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: References
 
Similar Threads
Primitive arrays
Object Reference Conversion
Which class represents array in java?
Conversion of reference values
Array of Objects