• 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

generics

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
interface Hungry<E> {void munch(E X); }

what is 'E' here.Is it a type of class.I read about "wild card notations",i understood them.I am not getting the meaning for say,

class abc<T>{
}

where do we use this kind of notation?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See: Sun Java Language Guide - Generics.

The E and the T stand for types that are filled in later. For example in your class abc<T>, when you are going to use this class somewhere in your program, you must instantiate it by providing a real type, for example abc<String> obj = new abc<String>();
 
Author
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This generics paper from Sun (Gilad Bracha) is also a great introduction to the subject (although a bit academic in tone, so may be harder to read). It's linked at the bottom of the article that Jesper posted.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another very good website with everything you'll ever need to know about generics is Angelika Langer's Java Generics FAQ. It does go very deep into the details, probably deeper than what you need to know for the SCJP, however.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic