Java Generics and Collections
Publisher: O'Reilly Media
Released: October 2006
Pages: 286

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

Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillyJava Generics and Collections
 
4.8

(based on 5 reviews)

Ratings Distribution

  • 5 Stars

     

    (4)

  • 4 Stars

     

    (1)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (0)

  • 1 Stars

     

    (0)

Reviewed by 5 customers

Sort by

Displaying reviews 1-5

Back to top

(4 of 4 customers found this review helpful)

 
5.0

(Resubmit) "The Java Generics" book ...

By Bloggerkedar

from Sunnyvale, CA

About Me Developer, Educator

Pros

  • Accurate
  • Concise
  • Easy to understand
  • Helpful examples
  • Well-written

Cons

    Best Uses

    • Expert
    • Intermediate

    Comments about oreilly Java Generics and Collections:

    It's perhaps too late to be reviewing this book, as technical books quickly become outdated. The book was written at the time of a Java release that marked the "new beginnings" of the formidable Java platform, the Java 5 release, back in 2005. This book review is written in 2013. Generics are an inseparable part of Java Programming Language. Though you'd like to think that it were (somehow) optional to know Generics, it's not the reality. You must be thorough with Generics. I agree that not all of us are library or API designers/implementors, but all of us are users of Java API; and a well-written, "modern" Java API uses Generics heavily. As a result, it quickly becomes imperative to know what Java Generics are.

    And if you want to understand Generics, this is the book to get and read. Look no further. The treatment of Generics has not changed (and perhaps will not change) across Java releases. What was true in 2006 about them will be true for quite some time (with minor improvements). And both Naftalin and Wadler have done an exceedingly good job of providing a thorough, lively and almost perfect treatment of this arguably the most divisive Java language feature.

    The prerequisite to reading this book (like, perhaps any other book) is to look at both Generics as a concept and their particular implementation adopted by the Java Platform with an open mind. If you have preconcived notions about this (which is not bad), this book is not for you. You should then be on the Java Community Process (JCP) mailing list about Generics.

    I appreciate this book mainly because it tries to "inform", not "impress". Many (even popular) technical books tend to do the opposite. With lucid examples, the book helps getting to the bottom of the "whys". It also brings out the synergy between the Java 5 language features that makes the whole greater than just the sum of its parts. After/while reading the book, you might see how the controversial autoboxing/unboxing, varargs methods, the foreach loop work in unison to deliver toward a common goal -- typesafe collections of Java objects.

    It's likely that you just hate the compile-time type safety. Perhaps you come from a refreshing and liberal dynamic scripting language like JavaScript and believe that compile-time type safety does not alleviate you of testing your code. You should then consume Generics as a necessary evil when programming in Java. But even then, if you are willing to accept that type safety has some benefits especially in the context of the Java programming language, read this book.

     
    5.0

    Superb

    By Wendell Murray

    from Southeastern Pennsylvania

    About Me Designer, Developer

    Verified Reviewer

    Pros

    • Accurate
    • Concise
    • Easy to understand
    • Helpful examples
    • Well-written

    Cons

      Best Uses

      • Expert
      • Intermediate

      Comments about oreilly Java Generics and Collections:

      The O'Reilly series of books on Java and Java-related topics is outstanding. This is one more outstanding book in that series. This book is well-organized, the material is well-presented and all details - many of which I beforehand was only vaguely or not all aware of - are included.

      Noteworthy among various other features is the explanation of terms such as "contract" which, as the authors note, is rarely defined but widely used in texts on Java. The authors note on page 157 (Chapter 11, section 4 Contracts) "you are likely to come across the term contract, often without any accompanying explanation". True enough, so the authors proceed to give a clear explanation of what "contract" means in regard to software.

      This is typical of the excellent exposition of some complicated details in the functioning of generics and of the Collections framework in general.

      (2 of 2 customers found this review helpful)

       
      5.0

      Finally, A Book Devoted To Generics And Collections

      By Dave Walz-Burkett

      from Undisclosed

      Comments about oreilly Java Generics and Collections:

      Ever since the release of Java 5, I've been keeping my eyes open for a book that describes what I believe to be the most powerful new feature of Java - generics. The new book published by O'Reilly, Java Generics and Collections covers the topic in spades. As a bonus, the second half of this book examines the Java Collections Framework. Since the Collections Framework was rewritten to incorporate the use of generics, it makes perfect sense for the authors to spend a reasonable amount of time describing the new interfaces.

      A brief introduction highlights the use of generics, autoboxing, foreach loops, generic methods and varargs. The examples are written using the Collections Framework. Subtyping and the use of wildcards follow the introduction and begin to show the real power of generics.

      Getting past the basics, a chapter devoted to the Comparable and Comparator interfaces describes some very useful concepts, such as how to use the Comparable interface to find the minimum or maximum element in a collection. The use of enumerated types is briefly covered here, as well as the concepts of multiple bounds, bridges and covariant overriding.

      A chapter describing how to declare a generic class helps you build your own classes. Following that is a useful chapter that describes how the design of generics is evolutionary, not revolutionary. It details how generics in Java 5 allow you to gradually migrate your legacy code, rather than replace it all at once.

      If you use generic types in casts, instance testing, exceptions or arrays, a chapter on reification warns you of rough edges and limitations you may find and describes some workarounds. How generics changes reflection is also covered.

      The last two chapters of the first half of the book describe how to use generics effectively in your code and provide samples of how implementations of select design patterns can take advantage of generics.

      The second half of the book, which dives into the Collections Framework, starts with a quick chapter called 'Preliminaries' that spends time discussing underlying concepts, such as the Iterable interface. Thread safety issues are covered in this chapter as well. Thread-safe concurrent collections were introduced in Java 5 and their use, as compared with synchronized collections is also discussed.

      The Collection interface is given its own chapter, which is important considering that it defines functionality common to any type of collection other than maps. Following are chapters describing sets, queues and lists. The Map interface also warrants its own chapter, in which the available methods and the various map implementations are discussed. The comparative performance of different set, queue, list and map implementations is shown in tables at the end of each chapter.

      Following the Collection and Map interface chapters is the final chapter which describes the Collections class in detail. The Collections class contains static methods that operate on collections or return them.

      I found the code and diagrams in this book very easy to understand and a great resource when trying to decide which collection or map implementation to use for a specific problem.

      Once you learn how to take advantage of generics, you'll begin to write more useful, reusable code. This book now occupies a space on my shelf next to my Algorithms and Data Structures books.

      (0 of 2 customers found this review helpful)

       
      5.0

      Egyptian JUG Review

      By Ahmed Hashim

      from Undisclosed

      Comments about oreilly Java Generics and Collections:

      Reviewd By Islam Mahgoub (http://www.egjug.org/user/771)

      In the past, I wondered a lot about Java Generics, and how

      could I use it, how it's implemented in Java, what goes behind the scenes, How

      could I evolve my code to use Java Generics, what about the differences between

      Java Generics and C++ templates, what does the phrase "Java generics are

      defined by erasure" mean, and a lot of other questions concerning Java recently

      added features to support generics.

      This book was recommended to me by a friend, really it's a

      great recommendation, I have found answers to the most of my questions concerning

      Java Generics and Collection framework.

      At the end, I think this book is suitable for both, a Java

      developer who know nothing about Java Generics and Collection and wants to

      start his journey with Java Generics and Collection framework, and also a Java

      expert who already has a good knowledge about Java Generics and Collection

      framework, but wants a more deep understanding of this topic, and wants to know

      how to use this feature in a professional way, and what goes behind the scenes.

      Read the complete review. (At the end, I think this book is suitable for both, a Java

      developer who know nothing about Java Generics and Collection and wants to

      start his journey with Java Generics and Collection framework, and also a Java

      expert who already has a good knowledge about Java Generics and Collection

      framework, but wants a more deep understanding of this topic, and wants to know

      how to use this feature in a professional way, and what goes behind the scenes.

      )

      (0 of 1 customers found this review helpful)

       
      4.0

      Greenvile Java Users Group - Moderator

      By John Yeary

      from Undisclosed

      Comments about oreilly Java Generics and Collections:

      The Java Generics book provides an in-depth analysis of the new Generics and Collections APIs in Java 5 and 6. The book provides a level of detail on this new technology that can not be found elsewhere. This book is generally not for a novice programmer due to the level of architectural details and theory. It provides a seasoned programmer with a comprehensive examination of why and how the Generics and Collections APIs were modified, as well as, the design decisions and impact. The book provides the programmer with the information they need to make informed decisions on which type of Collection to use, and the associated pitfalls based on design decisions.

      The only issue I found with the book was that it did not provide enough concrete examples. The code was provided generally in code snippets which do not provide enough detail.

      The book is a definite choice for the advanced Java programmer and architect. If you are serious about learning these new technologies: this is the book to get.

      Displaying reviews 1-5

      Back to top

       
      Buy 2 Get 1 Free Free Shipping Guarantee
      Buying Options
      Immediate Access - Go Digital what's this?
      Ebook: $27.99
      Formats:  APK, DAISY, ePub, Mobi, PDF
      Print & Ebook: $38.49
      Print: $34.99