This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generics" Watch "generics" New topic
Author

generics

radhika ayirala
Greenhorn

Joined: Aug 28, 2007
Posts: 24
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?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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>();


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Peter Mularien
Author
Ranch Hand

Joined: Sep 06, 2007
Posts: 84
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.


Author, Spring Security 3 (the Book), Packt Publishing, 2010
SCJP, OCP
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generics
 
Similar Threads
Question on generics
Compile fails or exception for this one
NEED GUIDANCE on SCJP1.5 exam topics
K & B Generics Quiz question.
Can't customed generic mehtod use "super"?