I need a tutorial about Generics in java, the tutorial documents on the Oracle website are very confusing, can anyone give some resources about Generics?
-
[This earlier question](http://stackoverflow.com/questions/490091/java-generics) has some links to resources as well as its own great description. The book referenced in the accepted answer is the best resource you will find. – justkt Apr 27 '11 at 19:19
-
3how is the document too confusing? – Woot4Moo Apr 27 '11 at 19:19
-
http://www.javacodegeeks.com/2011/04/java-generics-quick-tutorial.html – Adam Apr 27 '11 at 19:20
-
Thanks guys for providing me such good tutoiral! – Apr 28 '11 at 09:07
5 Answers
I suggest the official Java tutorial on generics: Lesson: Generics. It provides a really gentle introduction with hands on examples.
Angelika Langer maintains a quite good FAQ as well.
Also you need to know that generics are way to enforce compile time checking of your code to make sure the Objects in a collection are the object you think it is. Otherwise you can get ClassCastExceptions and other nasty run-time errors if the Object in a list is a Number when you thought it was a String.
- 5,419
- 3
- 37
- 60
You should have googled
well Try to go through Josh Bloch stuff,The creater of great generics,secondly, I guess generics tutorials at Oracle Site is most basic in nature.Dont expect easy stuff than that
- 5,959
- 12
- 54
- 90
I would recommend reading the Generics chapter in Herb Schildt's Java Complete Reference. Its a very gentle learning curve. If you want advanced treatise , go for the O'Reilly book Java Generics ( and collections )...
- 7,313
- 5
- 36
- 51