Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Help Java G Java generic

Related Tutorials


Share on Google+Share on Google+

Java generic

Java 1.5 provides number of new features to the Java Language including "Java Generics".

Java generic


Java 1.5 provides number of new features to the Java Language including "Java Generics". Using generics makes the application more reliable by detecting more bugs at compile time. ?Collections? framework is one of the places where Generics are most used. Until the introduction of Generics, when you take an element out of a collection they required a typecast i.e. you need to type cast it to the type of element that is stored in the collection. This is not only an inconvenient process but unsafe also. The compiler doesn't check that your have cast the element same as the collection's type. This can cause the application fail at run time.

Generic programming lets you write code that can work for many types of data. The information about the type of a collection can be provided to the compiler using Generics. Now the compiler can check the usage of collection correctly as well as you are not required to type cast the values retrieved from collection because of its support for correct auto type-casting feature.

Follow the link for complete tutorial :  Click here

Read more at:



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 11, 2009

Related Tutorials

Discuss: Java generic  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image