Java Reference
In-Depth Information
improves readability. We introduce the enhanced for loop in Chapter 2 and explain it
in more detail in Chapter 10 after we have described the object types with which the
enhanced for loop works.
Metadata -InChapter 4 we encounter the @Override annotation. It falls under the
category of metadata or “data about data.” In this case, it is better thought of as “data
about code”. The new metadata facility, also called the annotation facility, is designed
to use an “annotation” in your code that greatly reduces much of the boilerplate code
that would be required in previous versions of Java.
An annotation is a new 5.0 language element that begins with “@ . Some annotations
are processed by the javac compiler and some require the new annotation processing
tool apt . There are currently only three annotations in the beta release of version 5.0.
However, now that the metadata framework is available, we anticipate the appearance
of many useful annotations and annotation processors in the future.
Formatted input and output and varargs -InChapter 5 we discuss how to format
numerical output with Java. Version 5.0 finally adds the oft-requested ability to produce
formatted output easily in the form of a printf() method that behaves very similarly
to the printf() function in the C/C ++ stdio library. There is also a new formatted
input feature that is described in Chapter 9.
Both these features rely on another new feature known as “varargs”, which stands for
“variable argument list'” in which the number of parameters passed to a Java method is
not known when the source is constructed. Varargs is a useful new feature that can be
of value in your own code, not just in the new printf() feature. Chapter 10 presents
another EoD enhancement that provides for automatic format and output of the elements
of an array (see the java.util.Arrays class). This feature really has nothing to do
with printf or varargs ,but we mention it here because it eases the amount of work
that was necessary in pre-5.0 releases to output all the elements in an array in a nicely
formatted style.
Static import - Release 5.0 includes a new technique for accessing Java static methods
and constants in another class without the need to include the full package and class
name every time they are used. (We explain what the terms class , package , static , import ,
etc., mean in Chapters 3-5.) This new “static import” facility makes your code easier
to write and, since there's less of it, less error-prone. We discuss static import in more
detail in Chapter 5 after discussing import in general.
New pack200 hyper-compression JAR format - Chapter 5 discusses JAR (Java
Archive) files used to combine and compress Java class files. We also look at the new
pack200 format that compresses JAR files very tightly, reducing bandwidth and saving
download time. (This is not really an EoD change, but more of an “ease of deployment”
change.)
Graphics system improvements - Release 5.0 includes numerous bug fixes and minor
tweaks to Java's graphics subsystems known as AWT and Swing (see Chapters 6 and 7),
including reduced memory usage. In the EoD area, perhaps the biggest improvement is
that it is no longer necessary to call getContentPane() when using Swing compo-
nents (see Chapter 6 for details). Other enhancements include improved popup menu
Search WWH ::




Custom Search