...
The documentation fails to state whether after()
invokes compareTo()
or whether compareTo()
invokes after()
. In the Oracle JDK 1.6 implementation, the source code for after()
is as follows:
Code Block | ||
---|---|---|
| ||
public boolean after(Object when) { return when instanceof Calendar && compareTo((Calendar) when) > 0; } |
In this case, the two objects are initially compared using the overriding CalendarSubclass.after()
method. This invokes the superclass's Calendar.after()
method to perform the remainder of the comparison. But the Calendar.after()
method internally calls the compareTo()
method, which is delegated to CalendarSubclass.compareTo()
. Consequently, CalendarSubclass.after()
actually calls CalendarSubclass.compareTo()
and returns false
.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0f31533b729114d4-982f762d-4c3646bf-b92889f8-f94eb652b7ee469172e96ff3"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | [Class Calendar | http://download.oracle.com/javase/6/docs/api/java/util/Calendar.html] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="898b4bbbad47f68b-d5c3d7b2-43b244c7-bb7d93f8-28f156d141d4cd158d7e3847"><ac:plain-text-body><![CDATA[ | [[Bloch 2008 | AA. Bibliography#Bloch 08]] | Item 16: "Favor composition over inheritance" | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c092adec482649c4-0e4ee6ed-41604774-be5c97e5-6b2df41624355831fa5e927d"><ac:plain-text-body><![CDATA[ | [[Gamma 1995 | AA. Bibliography#Gamma 95]] | Design Patterns: Elements of Reusable Object-Oriented Software | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2165a27be6fc20de-b72291fe-474d401e-bea3ac89-320b01f154712e9633feaa09"><ac:plain-text-body><![CDATA[ | [[Lieberman 1986 | AA. Bibliography#Lieberman 86]] | Using prototypical objects to implement shared behavior in object-oriented systems | ]]></ac:plain-text-body></ac:structured-macro> |
...