Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Requried help in Generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Requried help in Generics " Watch "Requried help in Generics " New topic
Author

Requried help in Generics

kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102

Hello ranchers,

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..


kaushik Vira
-------------------------------------
SCJP, Preparing SCWCD..
kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102
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.

also Good Thread..
http://www.coderanch.com/t/447368/Programmer-Certification-SCJP/certification/BIG-WITH-COllections-Generics#1990975

now i can understand extend and super wild card... Both made my life easy with Java...
Venkata Saraswathi
Ranch Hand

Joined: Sep 27, 2008
Posts: 55
Hi,

Adding one more note to above is

As there is no equalent ArrayStoreException for Generics as exists for Arrays, It doesn't allow to add sub types.

have you done your exam? How difficult is it?

--Venkata.
kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102

It`s very easy then Exam lab.. my score is 74%.. but better we not discuss this on forum, we have "private message" option available here..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Requried help in Generics