-1

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?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • [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
  • 3
    how 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 Answers5

5

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.

Jesper
  • 202,709
  • 46
  • 318
  • 350
aioobe
  • 413,195
  • 112
  • 811
  • 826
0

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.

Justin Thomas
  • 5,680
  • 3
  • 38
  • 63
0

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

  1. Youtube link
  2. Tut
Ashish Agarwal
  • 6,215
  • 12
  • 58
  • 91
0

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 )...

Bhaskar
  • 7,443
  • 5
  • 39
  • 51
-1

you could try to read .pdf on generics in java here