Home » Generics » Page 3

Tag Archives: Generics

An Introduction to Generics in Java – Part 6

This is a continuation of an introductory discussion on Generics, previous parts of which can be found here. In the last article we were discussing about recursive bounds on type parameters. We saw how recursive bound helped us to reuse the vehicle comparison logic. At the end of that article, I suggested that a possible type mixing may occur when we are ...

Read More »

Advanced Java generics: retreiving generic type arguments

After their introduction in the JDK5, Java generics quickly became an integral element of many Java programs. However, as easy Java generics seem at first glance, as quickly a programer can get lost with this feature. Most Java programers are aware of the Java compiler’s type erasure. Generally speaking, type erasure means that all generic type information about a Java ...

Read More »

Subtyping in Java generics

Generic types introduce a new spectrum of type safety to Java program. At the same type, generic types can be quite expressive, especially when using wildcards. In this article, I want to explain how subtyping works with Java generics. General thoughts on generic type subtyping Different generic types of the same class or interface do not define a subtype hierarchy linear ...

Read More »

DAO layer – Generics to the rescue


Generics can be a powerful tool to create reusable code with the power of compile time verification (type safety..). Unfortunately I feel the main stream developers still afraid of it. However, in analogy to Hagrid’s spiders I would say that Generics are seriously misunderstood creatures… :-) I hope the following example will demonstrate how useful they can be. The Problem ...

Read More »

Java Generics Interview Questions

Generic interview questions in Java interviews are getting more and more common with Java 5 around there for considerable time and many application either moving to Java 5 and almost all new java development happening on Tiger(code name of Java 5). Importance of Generics and Java 5 features like Enum, Collection utilities are getting more and more popular on Java ...

Read More »