Home Help Java G Java generic



Java generic
Posted on: November 11, 2009 at 12:00 AM
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:

http://www.javajazzup.com/JavaGenerics.shtml

 

Related Tags for Java generic:


More Tutorials from this section

Ask Questions?    Discuss: Java generic  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.