This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics  RSS feed

 
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: 690
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
Boost this thread!