• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array is instance of an Object? No API in JavaDocs

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marco
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a API for class Arrays.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic