jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array is instance of an Object? No API in JavaDocs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array is instance of an Object? No API in JavaDocs" Watch "Array is instance of an Object? No API in JavaDocs" New topic
Author

Array is instance of an Object? No API in JavaDocs

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
This code is from Page 298 K&B book



How come Array is instance of an Object at Line # 11 ..There is no API that states that array extends/implements Object in JavaDocs..What is the logic behind this ?


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

An array is a built-in type in Java just like int or double. It isn't even mentioned in the JavaDoc because it's kind of a "special" language feature.

But arrays are objects and like instances of any class in Java they all extend the root type Object.

The Java language specification contains more detailed information on this ;-)

Marco
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

From JLS:

In the Java programming language arrays are objects (§4.3.1), are dynamically created, and may be assigned to variables of type Object (§4.3.2). All methods of class Object may be invoked on an array.


Array is a direct subclass of an Object.
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Thanks Marco
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

That's because Object is a regular class and arrays are a special language feature as I said above. The API documentation only contains the documentation for Java classes. Other language feature like the Java keywords are missing in the API doc, too. It's a simple fact that they are documented elsewhere and it is not theory. There are tons of specifications and documentations for Java which decribe the language parts you are missing in the API doc. The Java language specification (JLS) is one important additional documentation.

Marco
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

There is a API for class Arrays.


SCJP6.0,My blog Ranchers from Delhi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Array is instance of an Object? No API in JavaDocs
 
Similar Threads
Doubt on Pno-:286(K&B) Book(instanceof)
instanceof and Arrays
SCJP6 book page 298 errata
instanceof
Using instanceof operator