Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Creating Generic Classes

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the foll. from pg.602 from the Sierra-Bates exam. study guide-

public class AnimalHolder<T extends Animal> { // use "T" instead of "?"

T animal;

public static void main(String[] args) {
AnimalHolder<Dog> dogHolder = new AnimalHolder<Dog>(); // OK
AnimalHolder<Integer> x = new AnimalHolder<Integer>(); // NO!
}
}

It is mentioned that <T extends Animal> can be used to specify a bounds for the type. However, if I use <T super Animal>, it does not compile.

If the purpose of this construct is only to provide a way of bounding the type, why is it that I can't use super? Or, is it that there is no practical purpose to super which I am failing to see?

Regards
Percy
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this link


Discussed same issue

and

Similar issue
[ May 26, 2007: Message edited by: Chandra Bhatt ]
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic