-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
  • 669,072
  • 92
  • 771
  • 1,162
  • [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
  • 195,030
  • 44
  • 313
  • 345
aioobe
  • 399,198
  • 105
  • 792
  • 807
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,419
  • 3
  • 37
  • 60
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
  • 5,959
  • 12
  • 54
  • 90
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,313
  • 5
  • 36
  • 51
-1

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