aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generic Types changin method return types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generic Types changin method return types" Watch "Generic Types changin method return types" New topic
Author

Generic Types changin method return types

Tebogo Maitsapo
Greenhorn

Joined: Mar 26, 2010
Posts: 3
Source




How come suddenly the get() method returns an integer? Please be detailed in your answer as i would like to derive a rule from it. Or simply jst provide me with a rule/s around this problem. My first topic from south africa. Thank you
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18978
    
  40

Please do a search first next time. This question has come up before...

http://www.coderanch.com/t/497555/java-programmer-SCJP/certification/Generics-Class-Type-Parameter


And welcome to the JavaRanch...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tebogo Maitsapo
Greenhorn

Joined: Mar 26, 2010
Posts: 3
Thank you Henry. I did not know exately how to search,bt now i do. Thank you
Unmesh Chowdhury
Ranch Hand

Joined: Jun 20, 2010
Posts: 45
Actually, in your Test class String is not java.lang.String, it is the type parameter of generic class Test<String> which will be substituted by the actual type, and in your case, the actual type is java.lang.Integer. More generally, we can say type parameter is the placeholder of the actual type and we can declare any legal identifier as type parameter.


M.Sc. in CS, OCPJP6 93%
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3018
    
  10
Also, did you hear about that new search feature?
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Type- parameters could be Class names too for creating confusions. It is always better to think it as a T or E or anything you feel comfortable with, but ultimately it has to act as a placeholder.

SCJP 6.0 96%

(Connecting the Dots ....)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generic Types changin method return types