Java Reference
In-Depth Information
Stub ID = 2
Stub Date = 12/21/2012
Stub Developer = unassigned
Stub ID = 1
Stub Date = 12/21/2012
Stub Developer = unassigned
If you expected the output to reflect the order of appearance of @Stub annotations
in Deck.java ,youareprobablysurprisedbytheoutput'sunsortedorder.Thislackof
order is caused by getMethods() . According to this method's Java documentation,
“the elements in the array returned are not sorted and are not in any particular order.”
Note Java5introducedan apt toolforprocessingannotations.Thistool'sfunction-
alityhasbeenintegratedintothecompilerbeginningwithJava6- apt isbeingphased
out. My “Java Tools Annotation Processors” tutorial ( http://tutortutor.ca/
cgi-bin/makepage.cgi?/tutorials/ct/jtap ) providesatutorialonusing
the Java compiler to process annotations.
Generics
Java 5 introduced generics , language features for declaring and using type-agnostic
classes and interfaces. When working with Java's Collections Framework (which I
introduce in Chapter 5 ), these features help you avoid thrown instances of the
java.lang.ClassCastException class.
Note Although the main use for generics is the Collections Framework, Java's
class library also contains generified (retrofitted to make use of generics) classes
that have nothing to do with this framework: java.lang.Class ,
java.lang.ThreadLocal ,and java.lang.ref.WeakReference arethree
examples.
This section introduces you to generics. You first learn how generics promote type
safetyinthecontextoftheCollectionsFrameworkclasses,andthenyouexploregener-
icsinthecontextsofgenerictypesandgenericmethods.Afterlearningaboutgenerics
in the context of arrays, you learn how to use the SafeVarargs annotation type.
Search WWH ::




Custom Search