This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object and array ref Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object and array ref" Watch "Object and array ref" New topic
Author

Object and array ref

Ganesh Pujar
Ranch Hand

Joined: Mar 22, 2006
Posts: 45
Hi all

How is the following statement leagal?



As the C is a ref to Object (Not an array!, and anonymous array is agned to c)
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
It is valid because, in Java, an array is an object. You can even invoke the methods defined in the Object class, on an array


Mani
Quaerendo Invenietis
Ganesh Pujar
Ranch Hand

Joined: Mar 22, 2006
Posts: 45



In the above case, how can we ref x[4] using c! (i think c[4] is not possible )
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Object and array ref