• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

About generics

Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the Fruit class impliement the comparable <Fruit>
it has two subclasses : Apple and Orange

class Basket<T extends Fruit> extends ArrayList<T>
{ List Basket<T>=new ArrayList<T>();
void addBasket(Basket<? extends T> bas)
for (T ba:bas)

1> when i invole the addBasket method ,there are no complie time error,
but the words "ok" will NOT print?

2> the type parameters (T) which relate to static context ,is just like the field?

3> some problems about new T[100] or T t and t return t
may be I want to the sybmol standing for T in class file ?
this confuse me !
who can explain it
------- changchun
[ March 22, 2006: Message edited by: Changchun Wang ]
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic