Start reading Java Generics and Collections on the free Kindle Reading App or on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here.

Deliver to your Kindle or other device

Enter a promotion code
or gift card

Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Sorry, this item is not available in
Image not available for
Image not available

Java Generics and Collections [Kindle Edition]

Maurice Naftalin , Philip Wadler
4.2 out of 5 stars  See all reviews (28 customer reviews)

Digital List Price: $27.99 What's this?
Print List Price: $34.99
Kindle Price: $15.39
You Save: $19.60 (56%)

Free Kindle Reading App Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.

To get the free app, enter your email address or mobile phone number.


Amazon Price New from Used from
Kindle Edition $15.39  
Paperback $30.48  
Shop the New Digital Design Bookstore
Check out the Digital Design Bookstore, a new hub for photographers, art directors, illustrators, web developers, and other creative individuals to find highly rated and highly relevant career resources. Shop books on web development and graphic design, or check out blog posts by authors and thought-leaders in the design industry. Shop now

Book Description

This comprehensive guide shows you how to master the most importantchanges to Java since it was first released. Generics and the greatlyexpanded collection libraries have tremendously increased the power ofJava 5 and Java 6. But they have also confused many developers whohaven't known how to take advantage of these new features.

Java Generics and Collections covers everything from the mostbasic uses of generics to the strangest corner cases. It teaches youeverything you need to know about the collections libraries, so you'llalways know which collection is appropriate for any given task, andhow 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 andgeneric 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 anew level. If you want to take your software development practice toa new level, this book is essential reading.

Philip Wadler is Professor of Theoretical Computer Science at theUniversity of Edinburgh, where his research focuses on the design ofprogramming languages. He is a co-designer of GJ, work thatbecame 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 thetopic, it provides a crystal clear tutorial that starts with thebasics and ends leaving the reader with a deep understanding of boththe use and design of generics."
Gilad Bracha, Java Generics Lead, Sun Microsystems

Editorial Reviews


"This is a very good book on two fairly focused topics - generics and collections. If you plan to make best use of either or both, buy a copy." - Ian Elliot, VSJ, April 2007

Book Description

Master The New Features of Java

Product Details

  • File Size: 1002 KB
  • Print Length: 286 pages
  • Simultaneous Device Usage: Unlimited
  • Publisher: O'Reilly Media; 1 edition (October 17, 2006)
  • Sold by: Amazon Digital Services, Inc.
  • Language: English
  • ASIN: B0026OR2HM
  • Text-to-Speech: Enabled
  • X-Ray:
  • Word Wise: Not Enabled
  • Lending: Not Enabled
  • Amazon Best Sellers Rank: #521,148 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?

Customer Reviews

4.2 out of 5 stars
4.2 out of 5 stars
Share your thoughts with other customers
Most Helpful Customer Reviews
21 of 21 people found the following review helpful
5.0 out of 5 stars Excellent explanation of Java generics and its usage December 3, 2006
The intent of Generics is make your Java code type-safer. While Java is a strongly typed language, it lacks type-safety when it comes to using collections. Generics were added to the Java programming language in 2004 as part of J2SE 5.0. Unlike C++ templates, generic Java code generates only one compiled version of a generic class. Generic Java classes can only use object types as type parameters -- primitive types are not allowed. Thus a List of type Integer, which uses a primitive wrapper class is legal, while a List of type int is not legal.

Part I of this book provides a thorough introduction to generics. Generics are a powerful, and sometimes controversial, new feature of the Java programming language. This part of the book describes generics, using the Collections Framework as a source of examples.

The first five chapters focus on the fundamentals of generics. Chapter 1 gives an overview of generics and other new features in Java 5, including boxing, foreach loops, and functions with a variable number of arguments. Chapter 2 reviews how subtyping works and explains how wildcards let you use subtyping in connection with generics. Chapter 3 describes how generics work with the Comparable interface, which requires a notion of bounds on type variables. Chapter 4 looks at how generics work with various declarations, including constructors, static members, and nested classes. Chapter 5 explains how to evolve legacy code to exploit generics, and how ease of evolution is a key advantage of the design of generics in Java. Once you have these five chapters under your belt, you will be able to use generics effectively in most basic situations.

The next four chapters treat advanced topics.
Read more ›
Comment | 
Was this review helpful to you?
26 of 29 people found the following review helpful
4.0 out of 5 stars Good, but could be better February 6, 2007
Format:Paperback|Verified Purchase
Java generics are a welcome and important addition to the Java language, but because of their Erasure based implementation, they are somewhat limited and confusing to use.

This book is good in that it does cover many of the issues, and some interesting applications, but is I think limited in both explanations, and examples. Their section on Generics and Design patterns is a welcome one, but very short, and not very long on rationale or depth on other applications. If the examples they show is the only impact of generics on design patterns, something is wrong!

The standard Generics tutorials by Bracha and Langer, and the IBM DeveloperWorks series by Allen are more complete, and more descriptive, and free! I found the lumping of collections together with Generics ok, but a bit indicative that they ran out of real generics material. They are also IMHO a bit defensive on the long contested Erasure approach, but do explain their viewpoint well. They fault the C# and C++ approaches too quickly, noting the problems but not the corresponding solutions provided. Hopefully next versions of Java will (soon) provide reified versions of generics, it looks like it is in process now.

I did think it a worthwhile read, but not as much as expected.
Comment | 
Was this review helpful to you?
10 of 10 people found the following review helpful
This is one of the most in-depth books on the Java topics of generics and collections... Java Generics and Collections, by Maurice Naftalin and Philip Wadler. It covers the gamut from the basics to advanced...


Part 1 - Generics: Introduction; Subtyping and Wildcards; Comparison and Bounds; Declarations; Evolution, Not Revolution; Reification; Reflection; Effective Generics; Design Patterns

Part 2 - Collections: The Main Interfaces of the Java Collections Framework; Preliminaries; The Collection Interface; Sets; Queues; Lists; Maps; The Collections Class; Index

There have been quite a few books out that deal with the new Java 5.0 features, of which generics and collections are the featured items. But few go past the basics and common usage. Naftalin and Wadler devote this entire book to just those new features, which means they can spend a lot more time diving into the guts of how they work. There are nice "before generics" and "after generics" comparisons in the one section, so you can see how current coding styles can be enhanced and modified. I also liked how some basic design patterns were used to show how generics can be incorporated into standard designs. The collections material is just as helpful. Each type of collection is covered in detail, both for the reference on how it's coded as well as diagrams to show the architecture of that type of list. Again, when you get done with the section, there shouldn't be too many questions and issues surrounding collections that you can't answer or at least figure out.

Solid material, and definitely a title you'll want to have around when you start playing around with generics and collections...
Comment | 
Was this review helpful to you?
12 of 13 people found the following review helpful
Format:Paperback|Verified Purchase
It's a decent reference and a great read to go over generics and the collections framework. But don't get me wrong, it's nothing you can't get from just reading the Sun-provided API documentation or tutorials covering the topics.

It's comprehensive, sure... but the examples lean to near overkill on each topic in some areas. In other areas, there just isn't enough information or example code to really drive home the ideas.

It's average and worth the read. Not worth keeping around, though. It's one of those "read-once-then-give-it-to-a-friend" books. Like I said, though: you should definitely read this book if you're looking for more information on these topics. You'll just find yourself hitting resources online for more information in areas you are particularly interested in (concurrency w/ collections, for example).
Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
4.0 out of 5 stars "Java Generics and Collections" by Maurice Naftalin and Philip Wadler...
This is one of the first books on the Java Generics and Collections libraries. The book in question is - Java Generics and Collections, by Maurice Naftalin and Philip Wadler from... Read more
Published 24 months ago by Munish K Gupta
4.0 out of 5 stars Good book, on a terriblly poorly implemented feature.
Coming to JAVA from C++, I was thinking, hey, I need to read up on JAVA Generics, they are like C++ Templates and will help me program better. Read more
Published on April 29, 2013 by G. Powell
2.0 out of 5 stars Not a beginners book.
If you'r starting in Java, I recommend you to read first the information about Generics on Oracle documentation on their web page thoroughly and get familiar with it. Read more
Published on April 5, 2013 by PetRaf
4.0 out of 5 stars Not an easy read but absolutely worth it
I have mastered generics because of this book. Thanks! Be prepared to read some of the passages a couple of times. Read more
Published on March 24, 2013 by Axl Mattheus
3.0 out of 5 stars in depth on generics
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! Read more
Published on May 15, 2011 by Jeanne Boyarsky
2.0 out of 5 stars Not worth the price of purchase
This is a very basic introduction to the Java Collections Framework and simple use of generics. Emphasis on *simple*. Read more
Published on November 29, 2009 by Paul J. Ste Marie
5.0 out of 5 stars Concise and useful.
This book is very useful.

It is in fact, ridiculously concise. It may seem like a flimsy little workbook, but somehow a ton of information is fit in it. Read more
Published on August 14, 2009 by Amazon Customer
3.0 out of 5 stars Some good information
While the author spends too much time on what he thinks Java should be and what Sun needs to do to fix it, there is a lot of good and useful data to be had from the text.
Published on May 12, 2009 by Andre Untiedt
4.0 out of 5 stars Complete and precise in contents, somewhat confusing in presentation
You will find everything you need to know in this thorough book. But be prepared the most advanced chapters are right at the beginning: A tough start easing off to light reading at... Read more
Published on December 18, 2008 by ws__
5.0 out of 5 stars Explains the inexplicable
There are some difficult issues with Java Generics. This book does an excellent job explaining them. Read more
Published on October 16, 2008 by Frank Kieviet
Search Customer Reviews

More About the Authors

Discover books, learn about writers, read author blogs, and more.

What Other Items Do Customers Buy After Viewing This Item?


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category