A Boolean Rant

10 PM September 20, 2004

I’d like to take a moment to thank whoever it was who decided that Boolean should not implement Comparable in JDK 1.4. It must have been tough avoiding the temptation to add the five lines to the JDK, especially since Byte, Character, Short, Long, Float, Double, and String all have a compareTo() method.

Not only does this masterstroke assist the relentless fight against JDK bloat, it also causes some particularly bizzare ClassCastExceptions, enhancing my reputation amongst those that treat Java programmers like animist witch doctors, and assuring my continued employment.

So, thankyou. Thankyou so much.

(Sadly, this feature has been removed in JDK 1.5. As a workaround, I suggest throwing ClassCastExceptions from a java.util.TimerTask.)

By alang | # | Comments (2)
(Posted to javablogs, Java and Rants)


At 01:22, 21 Sep 2004 J Yu wrote:

well, jdk1.5 doesn't compile if(true>false).

philosophyically, it's quite wrong to define an order between true and false.

At 01:41, 21 Sep 2004 Alan Green wrote:

I agree with the philosophy, but in practice, when trying to define an ordering on a domain class, it's quite handy to compare Booleans.


Add Comment

(Not displayed)

(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)

© 2003-2006 Alan Green