what this code is signifying?Particularly the line
Ben Smither
Greenhorn
Joined: Sep 09, 2008
Posts: 4
posted
0
The type of the fn() can be different than the type of Class. So if you have Class <String>, you can return an Integer in fn().
Originally posted by Suddhasattwa Mukherjee:
what this code is signifying?Particularly the line
Nabila Mohammad
Ranch Hand
Joined: Nov 05, 2007
Posts: 661
posted
0
I thought they were supposed to be same - the class type and return type...
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Ken Truitt
Ranch Hand
Joined: Aug 23, 2007
Posts: 124
posted
0
Looks to me like a generic class (signified by the <T> after the class name, which is Class, although the class keyword is omitted) with a generic method.
The generic method is using the same identifier as the class so I would guess that it means that the method will be using the same type as the class itself.
So in the method, the method type is <T>, but the return type is T.
so somewhere if someone had new Class<String>(), all those T's would be String. Either that, or I'm wrong.