Tomorrow i have Exam, still my confidence in Generics is not at desired level. so i decided to go though the book of [Java Generics and Collections - By Maurice Naftalin, Philip Wadler ].
but I am not able to understand the following program, can any buddy simplify the explanation of the program.
From book :- Java Generics and Collections - By Maurice Naftalin, Philip Wadler
If any buddy having better suggestion about generics, then please let me know.. before exam i will go though that content.. I want to break SCJP With more then 95% but exam score is not my Goal.. knowledge behind the score is imp..
it`s funny to reply own Thread.. but i found something good... which are sharable..
There is 2 basic rules in Generics :- From book - [Java Generics and Collections - By Maurice Naftalin, Philip Wadler ].
Substitution Principle: a variable of a given type may be assigned a value of any subtype of that type, and a method with a parameter of a given type may be invoked with an argument of any subtype of that type.
The Get and Put Principle: use an extends wildcard when you only get values out of a structure, use a super wildcard when you only put values into a structure, and don't use a wildcard when you both get and put.