A Funny Java Flavoured Look at the World

Thursday, April 13, 2006

Generics Sample Chapter pdf

As I as was browsing O'Riellys virtual bookstore, dreaming of all the books I wish I could buy. I always click on the book to see if they have any sample chapters and to my delight this book had a sample chapter on Generics. As Generics is in the Sun Certified Java Programming exam I was in there like a shot and downloaded it.

To help any other fellow Java developer who are always going through the agonies of revising for the SCJP 5, I thought I would post the link.

As we are on the subject of Generics I thought I would add my thoughts on the subject (it is my blog after all). I think there has been quite a bit of fuss made about Generics. I appreciate that Generics aren't actually very Generic and everyone jumps on this point but I don't think they had much room to manoeuvre if they wanted to make Generics backward compatible. I'm pretty sure Generics wouldn't be used at all if they hadn't made it backward compatible.

I don't really mind how they have implemented Generics in Java (although I do not have any experience of this type of functionality in other languages) most of it is fairly simple, especially if you aren't mixing it up with legacy code. It does get a bit confusing when using the wildcard and the super and of course not forgetting extends can mean interfaces as well classes.

The one thing I do find confusing is the placing of the angled brackets <> and the look of the angled brackets, they just look a little bit out of place

My opinion is, although far from perfect but with the constraint of making Generics backward compatible, I think they did a decent enough job and once you get used to it, I think that Generics does let you create type safe collections and more importantly lets other developers easily understand what objects you are putting in the collection and avoids any casting errors.

I hope my ramblings and more importantly the link to the sample chapter helps anyone studying for their Java 5 exam. Here's the link to the file, from the Learning Java book



Post a Comment

<< Home