wood burning stoves 2.0*
The moose likes Java in General and the fly likes Reading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading "Adding Wildcards to Java" paper - a question" Watch "Reading "Adding Wildcards to Java" paper - a question" New topic
Author

Reading "Adding Wildcards to Java" paper - a question

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

In section 2.2; the paper justifies the need for super-bounded wildcards.

It gives one usecase for super-bounds which is in Comparator objects.

I'm not convinced by this argument. The inheritance tree is only

one level. If it were 4-5 levels deep; then it might make more sense.
In this case; using an implementation of Comparator<Object> is defeating the purpose of generics which is to implement type safe code. Instead I resort to writing code like this:

What do you think?
[ April 25, 2008: Message edited by: Pho Tek ]

Regards,

Pho
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

Originally posted by Pho Tek:
In this case; using an implementation of Comparator<Object> is defeating the purpose of generics which is to implement type safe code.

In this case yes. Consider another example though:

The thing is, for Comparator<A> and Comparator<Object> you have less values to sort on, but sometimes that's ok.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: Reading "Adding Wildcards to Java" paper - a question