Javadoc: An Observation

Disclaimer: I don't think this is not obvious (at least to some) and it (this observation) might have been made by many. I just reached it independently.

Javadoc is a great tool. It helps understand the basic hierarchy of an API and its public implementation. It's no replacement for looking into the source code, however. Sometimes, it might be misleading to draw conclusions based on what normal Javadoc shows, without looking into the code. Here is an example:

java.util.LinkedList illustrationThe java.util.LinkedList  inherits iterator() from java.util.AbstractSequentialList, which has a concrete implementation for iterator(). This method calls listIterator() which is inherited from java.util.AbstractList.  This method in turn calls listIterator(int index) which has concrete implementation in java.util.LinkedList  itself.

Thus, calling java.util.LinkedList.iterator()  will result in calling listIterator(int) on the same instance of LinkedList.

Did LinkedList really inherit iterator() from AbstractSequentialList in that case?

It of couse inherited the Java method named iterator(), but it does not inherit (and does override) the behavior for iterator().

Conclusion: Read source code, and open source software is beneficial.

Comments:

Post a Comment:
Comments are closed for this entry.
About

Welcome to my blog where mostly my work related thoughts are expressed.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today