Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about the generic methods : ExamLab final test

 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unable to interpret the meaning of the following code



I am not able to understand what the statement

means
what I know is this
1. This is generic method
2. that can be passed any instantiation which can be <T extends E>
3. Its return type is A

but I am not able to understand what <? super T> means after A

please help me
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a generic type declared in the GenClass which is E. E can be any class which extends A (or A itself). In the method declaration you declare another type T which extends E (E in itself is A or its subclass). The parameter the method gets is A<? super T>. This means that the method will receive an instance of A which has a type of T or a super class of T. To make this simpler to understand, lets replace A with a class from the Java API
The method parameter and return type are now easier to understand (I hope)...
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course they are easier now
after this nice explanation
thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic