File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes reference variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "reference variable" Watch "reference variable" New topic
Author

reference variable

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84

i heard that when we create an array ,the reference(address) of the array will be stored in ref variable
when i executing the above statement it is executing successfully .but i gave 0 to size of array .then what will be the address assigned to variable.


"I Love Java Ranch"
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18842
    
  40

saravanan ragunathan wrote:
when i executing the above statement it is executing successfully .but i gave 0 to size of array .then what will be the address assigned to variable.


Unlike some other languages, with Java, an array is an object -- so even if an array has no elements, it takes up some space (albeit a small amount).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

Primitive Arrays are actually objects in Java. The array object has instance variables like length(i've come across none other though..) which needs to be stored in the object space. In your case, the object will have length=0 stored in it. Of course that takes up some space,right?


OCPJP 6
saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
Vinoth Kumar Kannan wrote:Primitive Arrays are actually objects in Java. The array object has instance variables like length(i've come across none other though..) which needs to be stored in the object space. In your case, the object will have length=0 stored in it. Of course that takes up some space,right?


thanks for your explanation...
 
Consider Paul's rocket mass heater.
 
subject: reference variable