What do you think?


Java Generics and Collections: Speed Up the Java Development Process
This comprehensive guide shows you how to master the most important changes to Java since it was first released. Generics and the greatly expanded collection libraries have tremendously increased the power of Java 5 and Java 6. But they have also confused many developers who haven't known how to take advantage of these new features.
Java Generics and Collections covers everything from the most basic uses of generics to the strangest corner cases. It teaches you everything you need to know about the collections libraries, so you'll always know which collection is appropriate for any given task, and how to use it.
Topics covered include:
• Fundamentals of generics: type parameters and generic methods
• Other new features: boxing and unboxing, foreach loops, varargs
• Subtyping and wildcards
• Evolution not revolution: generic libraries with legacy clients and generic clients with legacy libraries
• Generics and reflection
• Design patterns for generics
• Sets, Queues, Lists, Maps, and their implementations
• Concurrent programming and thread safety with collections
• Performance implications of different collections
Generics and the new collection libraries they inspired take Java to a new level. If you want to take your software development practice to a new level, this book is essential reading.
Philip Wadler is Professor of Theoretical Computer Science at the University of Edinburgh, where his research focuses on the design of programming languages. He is a co-designer of GJ, work that became the basis for generics in Sun's Java 5.0.
Maurice Naftalin is Technical Director at Morningside Light Ltd., a software consultancy in the United Kingdom. He has most recently served as an architect and mentor at NSB Retail Systems plc, and as the leader of the client development team of a major UK government social service system.
"A brilliant exposition of generics. By far the best book on the topic, it provides a crystal clear tutorial that starts with the basics and ends leaving the reader with a deep understanding of both the use and design of generics."
Gilad Bracha, Java Generics Lead, Sun Microsystems
Java Generics and Collections covers everything from the most basic uses of generics to the strangest corner cases. It teaches you everything you need to know about the collections libraries, so you'll always know which collection is appropriate for any given task, and how to use it.
Topics covered include:
• Fundamentals of generics: type parameters and generic methods
• Other new features: boxing and unboxing, foreach loops, varargs
• Subtyping and wildcards
• Evolution not revolution: generic libraries with legacy clients and generic clients with legacy libraries
• Generics and reflection
• Design patterns for generics
• Sets, Queues, Lists, Maps, and their implementations
• Concurrent programming and thread safety with collections
• Performance implications of different collections
Generics and the new collection libraries they inspired take Java to a new level. If you want to take your software development practice to a new level, this book is essential reading.
Philip Wadler is Professor of Theoretical Computer Science at the University of Edinburgh, where his research focuses on the design of programming languages. He is a co-designer of GJ, work that became the basis for generics in Sun's Java 5.0.
Maurice Naftalin is Technical Director at Morningside Light Ltd., a software consultancy in the United Kingdom. He has most recently served as an architect and mentor at NSB Retail Systems plc, and as the leader of the client development team of a major UK government social service system.
"A brilliant exposition of generics. By far the best book on the topic, it provides a crystal clear tutorial that starts with the basics and ends leaving the reader with a deep understanding of both the use and design of generics."
Gilad Bracha, Java Generics Lead, Sun Microsystems
284 pages, Paperback
First published October 12, 2006
Ratings & Reviews
Friends & Following
Create a free account to discover what your friends think of this book!
Community Reviews
Displaying 1 - 29 of 29 reviews
May 15, 2011
My first thought on seeing the title “Java Generics and Collections” was wondering how there could be a whole book's worth of material on the topic. There is!
The first half of the book addresses generics. It includes concepts like reification (I learned a new word) that helps you better understand how generics actually work. It also includes a number of idioms for dealing with generics that you might not know even if you use generics.
The rest of the book covers the Collection API including how each one works and when to each type. This felt somewhat drawn out and repetitive. I would have liked to see the new classes in Java 5 and 6 highlighted more.
The downside: Some of the code examples were on the long side and some of the text required a lot of concentration. I also noticed a typo in the name of a Java class in a diagram which feels worse than in text. I also feel too broad an audience is covered. Parts assume you know nothing (in which case you'd be in over your head.)
Overall I recommend the book to learn about generics on a level of detail that surpasses the tutorials.
The first half of the book addresses generics. It includes concepts like reification (I learned a new word) that helps you better understand how generics actually work. It also includes a number of idioms for dealing with generics that you might not know even if you use generics.
The rest of the book covers the Collection API including how each one works and when to each type. This felt somewhat drawn out and repetitive. I would have liked to see the new classes in Java 5 and 6 highlighted more.
The downside: Some of the code examples were on the long side and some of the text required a lot of concentration. I also noticed a typo in the name of a Java class in a diagram which feels worse than in text. I also feel too broad an audience is covered. Parts assume you know nothing (in which case you'd be in over your head.)
Overall I recommend the book to learn about generics on a level of detail that surpasses the tutorials.
March 23, 2018
Very useful. Gives good insight of Collections
March 16, 2010
This is a pretty good description of Java Generics and how they differ from similar implementations in other languages. It also spends half the book going into detail on the Java Collection classes and how they make heavy use of generics to be much more useful.
I didn't expect to learn much from this and I was surprised how much useful info it contained. It's dry reading, particularly the second half of the book, but definitely useful for the Java programmer.
I didn't expect to learn much from this and I was surprised how much useful info it contained. It's dry reading, particularly the second half of the book, but definitely useful for the Java programmer.
February 17, 2009
This book was lame - I forgot why, but it definitely was lame.
July 4, 2016
Coverage is good.I would have liked application context oriented examples instead of numbers,double etc.Recommended to be read by Beginners.
May 17, 2019
While the book is dated, it is still useful especially with regards to understanding Generics. I found it useful as I was working on a refactoring to extract common code into a generic Superclass when I decided to pick up this book.
The book is divided into 2 parts, one on Generics and the other on the Java Collections Framework. These two parts feel entirely separate and since most would be reading it for Generics, the following is some guidance on which chapters to read if pressed on time:
Basic Generics: Chapter 1, 2, 4
Advance Generics/ Related Concepts: Chapter 3, 6, 7
Examples via Design Patterns: 9
For the other Generics chapters, they are related to dealing with legacy code/ libraries that uses raw types which might not be relevant for all since most of the current Java libraries should already be using Generics instead of raw types.
For the collections chapter, while dated, I still learnt something new (SkipLists, NavigableMap interface, etc.) from the chapters and it is a good review of many of the available implementations of Map, Set, List, etc and when to choose them. If I were less experienced with Java, it would have given a solid introduction to the Collections API, thus I would recommend if you are new to Java or would like a refresher in the Collections Framework. (ArrayDeque, NavigableMap, ConcurrentSkipListMap, etc., if these sound foreign, this part of the book would clear things up.)
The book is divided into 2 parts, one on Generics and the other on the Java Collections Framework. These two parts feel entirely separate and since most would be reading it for Generics, the following is some guidance on which chapters to read if pressed on time:
Basic Generics: Chapter 1, 2, 4
Advance Generics/ Related Concepts: Chapter 3, 6, 7
Examples via Design Patterns: 9
For the other Generics chapters, they are related to dealing with legacy code/ libraries that uses raw types which might not be relevant for all since most of the current Java libraries should already be using Generics instead of raw types.
For the collections chapter, while dated, I still learnt something new (SkipLists, NavigableMap interface, etc.) from the chapters and it is a good review of many of the available implementations of Map, Set, List, etc and when to choose them. If I were less experienced with Java, it would have given a solid introduction to the Collections API, thus I would recommend if you are new to Java or would like a refresher in the Collections Framework. (ArrayDeque, NavigableMap, ConcurrentSkipListMap, etc., if these sound foreign, this part of the book would clear things up.)
July 30, 2017
The book dives deep in to the details of Generics and how it is implemented in Java. But it will be bit difficult to comprehend if you don't have some basic understanding of Generics. The second part of the book covers Collections framework which you won't find interesting if you already worked with Java Collections. The author should consider releasing a book that covers only Generics. Overall, it is a decent book to learn about Generics.
Currently Reading
August 28, 2017Chapter 13 Set
- learn the various type of set and their usage
- General HashSet( constant performance)
- linkedHashSet ( faster iteration and ordering )
- Treeset (Sorting)
- ConcurrentSkiplistset(multi thread + sorting)
- CopyOnWriteArraySet ( small set size, more read than write, thread safe)
- for multi-thread use ConcurrentSkipListSet / Client symchronizing / use Collection.synchronize to get Synchronized implementatiom
- learn the various type of set and their usage
- General HashSet( constant performance)
- linkedHashSet ( faster iteration and ordering )
- Treeset (Sorting)
- ConcurrentSkiplistset(multi thread + sorting)
- CopyOnWriteArraySet ( small set size, more read than write, thread safe)
- for multi-thread use ConcurrentSkipListSet / Client symchronizing / use Collection.synchronize to get Synchronized implementatiom
This entire review has been hidden because of spoilers.
November 4, 2017
Well most of books for beginners do teach little amount of collections. But no one is as detailed as this.
May 3, 2019
Excellent book for advanced understanding of Java Collections Framework and how Generics work. The book is systematic and offers great examples. Maps and Sets part is a bit crammed.
December 19, 2021
It’s not for java beginners. The way author explains the concept requires readers having solid foundation and concentration. I’ve read this multiple times and each time I got something new.
August 8, 2022
Every developer working with a JVM based language should consider reading at least the first half of this books which covers generics.
December 22, 2022
I was interested only in the generics part of the book. This is a complicated concept and sadly this book failed to make clear explanations. Too dense I think.
October 24, 2007
Okay, I straddle two worlds. In one life, I labor through complex, terse, and often obscure works of philosophy. In the other, I blissfully bang out thousands of lines of code in my happy little IDE -- the famous editor VI (that's pronounced "Six" -- it's roman numerals. No really. I'm not making fun of your ignorance... I swear).
One thing I have noticed is that academic writing often forgoes altogether any concern for the readability of the text. Another is the noted absence of any examples or illustrative material that might actually have any bearing on reality.
(Need an example? Google "Brains in a vat")
But in happy computer land, I rarely find this to be the case. Mainstream books in programming tend to be practical and readable (Sometimes they get nauseatingly so. Example: [title: Head First Java]).
Java Generics and Collections, like me, straddles two worlds. And it does so with moderate success. While it certainly provides the details on generic and collections, it has its "Computer Science 502" moments.
The book is all about the facts. No cute illustrations. No gratuitous coffee jokes. No fanciful business problems that we will magically be able to solve with the help of Java Generics Man. Just the facts.
Wow... how refreshing.
But sometimes the text gets a little too terse. Huge chunks of code get explained in just a line or two (leaving the reader wondering about the details). Sometimes (as is the case in most of Chapter 3), major concepts are explained in self-referential ways, while no clear definitions for key concepts are offered.
Those moments left me frustrated, to be sure. If I wanted to try to figure out what someone else's code did, I'd read Java Puzzlers... or go download the source code to Eclipse.
But aside from those points, I've found this book very helpful in explaining the details of a system that the official Java documentation just doesn't adequately cover.
This book will land on my reference shelf with precious few other computer books -- the five or six (like [title:Applied Cryptography] and the CSS Reference Pocketbook) that have survived my cruel computer bookshelf purges.
One thing I have noticed is that academic writing often forgoes altogether any concern for the readability of the text. Another is the noted absence of any examples or illustrative material that might actually have any bearing on reality.
(Need an example? Google "Brains in a vat")
But in happy computer land, I rarely find this to be the case. Mainstream books in programming tend to be practical and readable (Sometimes they get nauseatingly so. Example: [title: Head First Java]).
Java Generics and Collections, like me, straddles two worlds. And it does so with moderate success. While it certainly provides the details on generic and collections, it has its "Computer Science 502" moments.
The book is all about the facts. No cute illustrations. No gratuitous coffee jokes. No fanciful business problems that we will magically be able to solve with the help of Java Generics Man. Just the facts.
Wow... how refreshing.
But sometimes the text gets a little too terse. Huge chunks of code get explained in just a line or two (leaving the reader wondering about the details). Sometimes (as is the case in most of Chapter 3), major concepts are explained in self-referential ways, while no clear definitions for key concepts are offered.
Those moments left me frustrated, to be sure. If I wanted to try to figure out what someone else's code did, I'd read Java Puzzlers... or go download the source code to Eclipse.
But aside from those points, I've found this book very helpful in explaining the details of a system that the official Java documentation just doesn't adequately cover.
This book will land on my reference shelf with precious few other computer books -- the five or six (like [title:Applied Cryptography] and the CSS Reference Pocketbook) that have survived my cruel computer bookshelf purges.
January 8, 2014
Finally, i've read this book! I have a point that i should finish every book that i've started to read. This book was an exception, because i wasn't able to finish it for a few years. I had all sorts of execuses not to read this book, some of them were a lack of time and a complete disinterest in the subject of this book.
I was wrong, the book is interesting. It's a sort of holy grail for those who want to know how generics work under the hood and where to apply them. As for me i was interested in the second part of it which is "Collections". It's nice and comprehensive guide that describes almost every entity in the Java 6 Collections API.
If i have read this books many years ago i would have avoided many pitfalls =)
My score 5/5
I was wrong, the book is interesting. It's a sort of holy grail for those who want to know how generics work under the hood and where to apply them. As for me i was interested in the second part of it which is "Collections". It's nice and comprehensive guide that describes almost every entity in the Java 6 Collections API.
If i have read this books many years ago i would have avoided many pitfalls =)
My score 5/5
February 13, 2011
Type systems kind of blow my mind, in particular things like bounded types and co-/contravariance Feels like 2 totally separate books, and the collections section was fairly dry. The first half, on generics, helped to make things clearer - will probably need a second read to solidify.
Read
May 6, 2013A must read on Generics... with Neil Gafter's blog and Angelika Langer's FAQ (even though they are sometimes hard to find, there are some true gems like the entry on how to instantiate a wildcard parameterized type despite the compiler's best efforts to prevent it).
Read
March 2, 2016WHAT HAVE YOU BEEN READING, MEMERS?
JAVA GENERICS AND COLLECTIONS. AREN'T YOU JEALOUS OF ME? I BET YOU'RE JEALOUS OF ME.
SOUNDS RIVETING! ARE YOU FINDING IT ACTUALFAX HALPFUL?
I'M LEARNING STUFF FROM IT. HOW USEFUL IT'S GONNA BE TO ME IS STILL UP FOR DEBATE.
JAVA GENERICS AND COLLECTIONS. AREN'T YOU JEALOUS OF ME? I BET YOU'RE JEALOUS OF ME.
SOUNDS RIVETING! ARE YOU FINDING IT ACTUALFAX HALPFUL?
I'M LEARNING STUFF FROM IT. HOW USEFUL IT'S GONNA BE TO ME IS STILL UP FOR DEBATE.
August 22, 2018
This book explains clearly on the concept of Java Generics. I become significantly more comfortable working with generics after reading this book. However, this book is a reference book and can be quite boring to read.
April 21, 2011
Strangely boring, given that I've enjoyed Wadler's writings on Haskell. Some very good sections (the first 100 pages); some incredibly boring ones (most of the Collections discussion).
April 26, 2011
I was concerned that this book would be tedious on such a narrow subject. The authors delivered the information directly and clearly. This was enough to keep everything interesting.
October 30, 2014
Great book that goes in depth of Java Generics which feels awkward initially to someone coming from other languages.
February 26, 2015
An interesting and succinct book which focuses on generics and collections, clearing many things regarding them. Probably a second read would be needed.
September 2, 2015
I read the collection API part. It is not as good a book and in-depth implementation details of API's is missing.
October 25, 2016
First half: really good.
Second half: mostly API reference.
Second half: mostly API reference.
December 22, 2016
The most comprehensive book on Generics as well as collection.A must have
March 27, 2020
Must read for generics in java.
Read
March 3, 2012Reflection, do, weak map
Read
January 22, 2018cool
Displaying 1 - 29 of 29 reviews


















