• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Generics  RSS feed

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I need to know what this does means :



Thanks and regards,
Satya
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's just a class that has four generic type parameters. So just as List<T> has one type variable that you have to provide when you create an instance, and Map<K, V> has two, this has 4.

Two of them have constraints. The type given for W has to be Request or a subclass of Request. The type given for V has to be Response or a subclass. The other two can be anything.

So you could create an instance of this class like this, for example:


Or you can subclass it like this (in this example the subclass fixes two of the types, and allows the other two to vary):
(assuming SpecialRequest is a subclass of Request)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!