wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Array's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Watch "Array New topic
Author

Array's

Pawan Arora
Ranch Hand

Joined: Sep 14, 2008
Posts: 105
What's the meaning of line
Array itself is an object
?
presumably like this int[] arr;
where arr is an object.
please clarify me.
thanks in advance for help.
Ismael Gimenez
Greenhorn

Joined: Oct 21, 2008
Posts: 9
Someone correct me if I am wrong but I think java treats an array as an object. That is to say, an array is a subclass of an Object and therefore inherits all the methods that the class object provides.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"ScummBar SoftDesign",
Please check your private messages.
-DOM
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yes, an array is an Object, hence the following is valid:
Pawan Arora
Ranch Hand

Joined: Sep 14, 2008
Posts: 105
So in statement like int[] arr, what is arr mean?
Paul Yule
Ranch Hand

Joined: May 12, 2008
Posts: 229
Originally posted by Pawan Arora:
what is arr mean?


arr is the name of the object you created. The int is the type of references your array can hold.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

The int is the type of references your array can hold.


<nitpick>int is a primitive type. int[] holds ints, not references to ints.

Object arrays hold references to objecs.</nitpick>


luck, db
There are no new questions, but there may be new answers.
Paul Yule
Ranch Hand

Joined: May 12, 2008
Posts: 229
True, I probably should have made that distinction but was afraid if I said "int is the type of value" it would be misleading or perhaps confusing later when you work with references to objects which is where this thread started.

I'll provide an example of what we mean just in case.

[ October 22, 2008: Message edited by: Paul Yule ]
 
Don't get me started about those stupid light bulbs.
 
subject: Array's
 
Similar Threads
Array problem
casting Objects
Arrays
Object[] and Object
Is every array an Object?