






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































New naming scheme: Java 5
(Tiger)
New features 1.^
Auto-box and auto-unbox
Generics
for each
statement
Varargs
Formatted I/O
Enumerations
Static import
Metadata
API changes
Auto boxing/unboxing also occurs on methodcall/return^ Class foo {
static int bar(Integer i) { return i; }public static void main(String argv[]){
Integer iX = bar(123);System.out.println(iX); } }
class Foo
T x;
// instance variable
Foo(T y) { x = y; }
//constructor
T getFoo() { return x; }
// getter
String whoAmI() {
// reflection
return( x.getClass().getName()); } }
Foo
// unbox
dbl.whoAmI();
// Java.lang.Double
©2007 by Spencer Rugaber
-^
Denoted by
?
-^
Normally, references to a generic formal parameter (
T
)
within a generic stand for the same actual argumentspecified at generic instantiation time
-^
It is sometimes useful to allow a reference to any legalactual argument and not just
T
class foo
int bar(foo<?> x) { ...}
//? instead of T
} foo
-^
The use of wildcards does not modify boundedness of
T
,
but wildcard themselves may be bounded
-^
You can even bound them from below^ <? super
classname
collection
extraction