Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array's

 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ScummBar SoftDesign",
Please check your private messages.
-DOM
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, an array is an Object, hence the following is valid:
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So in statement like int[] arr, what is arr mean?
 
Paul Yule
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Paul Yule
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic