Java Generics

Recent Articles

Cast in Java Generics

In this tutorial let us discuss about different aspects of type cast with respect to Java generics. Generics was initially idealized for collections framework. In collections there were lots of cast done. In a way, one of the main objective of Java generics is to help programmer reduce explicit type cast and provide type-safety. Before […]
Published to Java Tutorial on 12/03/2014.

Java Generics Basics

This Java generics tutorial is to introduce basic terminologies related to generics. They are demonstrated with example code and this tutorial is for beginners only. Java Generics Example Before we go into detail let us see an example for generics in Java. This is to recall and continue from our previous tutorial for introduction to […]
Published to Java Tutorial on 18/02/2014.

Java Generics Introduction

“Java generics” gives the ability to parameterize a type or method and use it in a generic way. A Java class can be defined using a parameter type and the defined parameter can be used inside that class scope as a formal type. For example, in Java collections ArrayList will serve as an apt example […]
Published to Core Java Tutorial on 11/02/2014.

Type Erasure

Type erasure is the technique using which the Java compiler translates generic / parameterized type to raw type in Java generics. Type erasure is applicable in the context of generics. Following example illustrates a simple usage of generics in Java. package; import java.util.HashMap; import java.util.Map; public class TypeErasure { public static void main(String args[]) […]
Published to Core Java Tutorial on 27/07/2010.