Generics and Collections in Java 5 by Naftalin M., Wadler Ph.

By Naftalin M., Wadler Ph.

This finished consultant indicates you ways to grasp crucial adjustments to Java because it was once first published. Generics and the tremendously extended assortment libraries have enormously elevated the ability of Java five and Java 6. yet they've got additionally careworn many builders who have not recognized the best way to make the most of those new positive aspects.

Java Generics and Collections covers every thing from the main simple makes use of of generics to the strangest nook circumstances. It teaches you every little thing you want to find out about the collections libraries, so you will always be aware of which assortment is suitable for any given job, and the way to take advantage of it.

themes coated include:

  • Fundamentals of generics: sort parameters and commonplace methods
  • Other new good points: boxing and unboxing, foreach loops, varargs
  • Subtyping and wildcards
  • Evolution now not revolution: commonly used libraries with legacy consumers and universal consumers with legacy libraries
  • Generics and reflection
  • Design styles for generics
  • Sets, Queues, Lists, Maps, and their implementations
  • Concurrent programming and thread security with collections
  • Performance implications of other collections

Generics and the recent assortment libraries they encouraged take Java to a brand new point. in order to take your software program improvement perform to a brand new point, this ebook is key reading.

Philip Wadler is Professor of Theoretical desktop technological know-how on the college of Edinburgh, the place his learn makes a speciality of the layout of programming languages. he's a co-designer of GJ, paintings that grew to become the root for generics in Sun's Java 5.0.

Maurice Naftalin is Technical Director at Morningside gentle Ltd., a software program consultancy within the uk. He has so much lately served as an architect and mentor at NSB Retail structures plc, and because the chief of the customer improvement workforce of an enormous united kingdom executive social provider system.

''A fantastic exposition of generics. by way of some distance the easiest publication at the subject, it presents a crystal transparent instructional that starts off with the fundamentals and ends leaving the reader with a deep knowing of either the use and layout of generics.'' Gilad Bracha, Java Generics Lead, solar Microsystems

Show description

Read Online or Download Generics and Collections in Java 5 PDF

Best programming: programming languages books

The J2EE Tutorial

* mild, self-paced introductions to servlets, JSP, JDBC, EJBs, XML, JMS, JNDI, and plenty of different key themes. * Follows an analogous procedure and structure that made The JavaTTM instructional a world best-seller! * comprises CD-ROM containing all content material, examples, and either the J2EE and J2SE model 1. three software program systems.

Informatik kompakt: Eine grundlegende Einfuhrung mit Java

Die Autoren geben eine fundierte Einf? hrung in die Informatik, die von Anfang an die Zusammenh? nge zwischen den Teilgebieten des Faches betont. Das Buch ist kompakt, weil der gemeinsame Kern der verschiedenen Informatikgebiete betrachtet wird. In einer integrativen Sichtweise werden Modellierung, abstrakte Datentypen, Algorithmen sowie nebenl?

Durchstarten mit HTML5

HTML5 ist die neueste model der Markup-Sprache, die das internet noch einmal gehörig auf den Kopf stellt. Obwohl die Entwicklung noch nicht abgeschlossen ist, werden viele HTML5-Elemente von modernen Browsern schon jetzt unterstützt. Zeit additionally, die Neuerungen zu erkunden und sich healthy für die Zukunft zu machen.

Additional info for Generics and Collections in Java 5

Sample text

Since generics are implemented by erasure, it also follows that two distinct methods cannot have signatures with the same erasure. A class cannot overload two methods whose signature has the same erasure, and a class cannot implement two interfaces that have the same erasure. For example, here is a class with two convenience methods. One adds together every number in a list of numbers, the other concatenates together every string in a list of strings. 10. 8 Type parameters are in scope for nested, non-static classes.

8 Restrictions on wildcards Wildcards may not appear at the top-level in class instance creation expressions (new), in supertypes (extends and implements) and or in explicit type parameters in generic method calls. Instance creation In a class instance creation expression, if the type is a parameterized type, then none of the type parameters may be wildcards. For example, the following are illegal. >(); // compile-time error Map map = new HashMap(); // compile-time error This is usually not a hardship.

Depending on how we set things up, we may prohibit comparison of apples with oranges or we may permit such comparison. 1 prohibits comparison of apples with oranges. Here are the three classes it declares. } Each fruit has a name and a size, and two fruits are equal if they have the same name and the same size. Apples are compared by comparing their sizes, and so are oranges. Since Apple implements Comparable, it is clear that one can compare apples with apples, but not with oranges. The test code builds three lists, one of apples, one of oranges, and one containing mixed fruits.

Download PDF sample

Rated 4.49 of 5 – based on 31 votes