• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading "Adding Wildcards to Java" paper - a question

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic