| 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: 1221
|
|
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: 1221
|
|
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: 1046
|
|
|
There is a API for class Arrays.
|
SCJP6.0,My blog Ranchers from Delhi
|
 |
 |
|
|
subject: Array is instance of an Object? No API in JavaDocs
|
|
|