• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Generics

 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, generics were an enhancement to the Java Language version 5.0 and greater.

Kaydell
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic