Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics

 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, generics were an enhancement to the Java Language version 5.0 and greater.

Kaydell
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic