• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Generics, a brain dump

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right I'm having some real problems with understanding generics, I've read K&B chapter 7 a few times and I've just had a look at the generics tutorial by Gilad Bracha.

So I'm going to brain dump everything I know for sure, and attempt to explain some of the more complicated stuff

Basic


Legacy generics


Polymorphism


Wild cards


Generic declarations, this is where I start getting sketchy


Ok so I don't really understand the more complex stuff, I just about understand the above example, but could someone walk through a few embedded generic example?

So something like


Also when you have


I don't understand this syntax or where it would get used etc. etc.

And I think this might be the last example (at least as far as the exam goes).


I'm uncertain of the use of these

Thanks in advance, I can't afford to not understand these fully, there seem to be lots of questions involving generics
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul lemme add a few things to your list if you already don't know this





 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As of E, T, K, V ...

From "Head First Java":
"You can use anything that's a legal Java identifier. That means anything that you could use for a method or a variable name will work as a type parameter. But the convention is to use a single letter (so that's what you should use), and a further convention is to use "T" unless you're specifically writing a collection class, where you'd use "E" to represent the "type of the Element the collection will hold."

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic