Lokesh
( SCBCD 5, CCENT, SCJP 5 )
lokesh chenta wrote:it is defining "T" as generic type but that is scoped for the whole class. Where as "U" is a generic type which can be used only in inspect().
Alan Blass wrote:
lokesh chenta wrote:it is defining "T" as generic type but that is scoped for the whole class. Where as "U" is a generic type which can be used only in inspect().
Hi! Why do you need to specify T as generic type scoped for the whole class since T is already private and is available for the whole class?
or alphabet "YOU" for method inspect() since it is already understood it is for the method's scope.
I mean why do you need to specify it?
Thanks.
alphabet "YOU" for method inspect() since it is already understood it is for the method's scope.
This understanding is not correct. T is not private to class. Reason for specifying 'T' as generic type explicitly is to tell compiler that we are generic reference which shall be replaced by actual implementation class later on.Why do you need to specify T as generic type scoped for the whole class since T is already private and is available for the whole class?
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
Ove Lindström wrote:
the compiler/jvm will write me this method:
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet wrote:
Therefore it is legal to do:
Ove Lindström wrote:Well, yes, but we could argue if it is legal or not when it throws you an error... ;)
Ove Lindström wrote:Don't confuse the young ones.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|