aspose file tools*
The moose likes Beginning Java 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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generics" Watch "Generics" New topic
Author

Generics

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Hi all,
I have read many articles on generics in java but still i am not clear with the concept,what are generic types?,generic methods? ,what is the use of generics in a program?.Please if anyone can explain me about generics with a easy to understand explanation and a example so that i can understand it will be realy kinda of you.


Thanks in advance.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Generics are a way of improving the type-safety of your code, by giving explicit types where previously one typically had to use Object.

It makes the code easier to understand, once you understand the syntax, and helps the compiler to spot certain types of programming error.

Generics type information is not included in the class files generated by the compiler ("type erasure") so they have little or no impact on how your program runs.

For more, search java.sun.com for "generics" and find their article.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

By the way, generics were an enhancement to the Java Language version 5.0 and greater.

Kaydell
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Generics