• 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

Generic : Bounded type parameter

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Its compiles fine :
1) but my problem is with the hierarchy
String does implements Comparable but it doesn't extends it
They why I am not able to catch this problem. Isn't it a wrong interpretation indicated by generic syntax for method.

2) Syntax says : <U [extends SuperClass [& Interface[,Interface]]]
Now,
What if I dont want to use extend but does need to allow classes that implements particular interface.
Some thing like
<U [& Interface[,Interface]]]

3)Why generic doesnt distingues between "extending something" and "implementing something". There must be a solid reason behind this for sure.
 
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont know the reason for "Why"

But that's the rule in Generics which is unlike the general rule.

In Generics , whether you implement the interface or extend a class ,
it willalways be written as < T extends Class/Inteface >
It will never be written as < T implements Interface>

The words implement is not used in Generics.

Hope some one can giv you the why part of the answer...
 
Sanjeev Dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nabia,

Thanks for the response but i m still looking for "why". Why it dont distinguishes between extend and implement.


Thanks,
Sanjeev
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic