Home » Tag Archives: Generics

Tag Archives: Generics

How to Map Distinct Value Types Using Java Generics

java-logo

Occasionally the average developer runs into a situation where he has to map values of arbitrary types within a particular container. However the Java collection API provides container related parameterization only. Which limits the type safe usage of HashMap for example to a single value type. But what if you want to mix apples and pears? Luckily there is an ...

Read More »

An Introduction to Generics in Java – Part 6

java-logo

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

java-logo

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

java-logo

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

java-interview-questions-answers

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

java-logo

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 »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close