Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource for learning Java generics? [closed]

Tags:

java

generics

I'm clearly in need of improving my knowledge in this Java field, or I'm doomed to produce "look the same but not exactly" code.
I'm already have the bases... but I'm looking for a training / tuturial oriented only to this.

Thanks

like image 722
Antoine Claval Avatar asked May 14 '09 17:05

Antoine Claval


People also ask

How can I learn Java generics?

Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

What is meant by reified generics in Java?

In Java, under the covers, they are the same thing - a List<Object> . This means that if you have one of each, you can't look at them at run time and see what they were declared as - only what they are now. The reified generics would change that, giving Java developers the same capabilities that exist now in .

Is it a good idea to use generics in collections?

By using generics, programmers can implement generic algorithms that work on collections of different types, can be customized, and are type safe and easier to read.

Can you use primitive types with generics in Java?

Using generics, primitive types can not be passed as type parameters.


1 Answers

  • Angelika Langer's Java Generics FAQs.
  • Oracle's Java Generics Tutorial
  • Joshua Bloch's Effective Java, Chapter 5 - Generics [pdf]
like image 100
Michael Myers Avatar answered Oct 09 '22 22:10

Michael Myers