February 2014
Beginner
1248 pages
62h 25m
English
Consider line 10 of Fig. 7.24:
ArrayList<String> items = new ArrayList<String>();
Notice that ArrayList<String> appears in the variable declaration and in the class instance creation expression. Java SE 7 introduced the diamond (<>) notation to simplify statements like this. Using <> in a class instance creation expression for an object of a generic class tells the compiler to determine what belongs in the angle brackets. In Java SE 7 and higher, the preceding statement can be written as:
ArrayList<String> items = new ArrayList<>();
When the compiler encounters the diamond (<>) in the class instance creation ...
Read now
Unlock full access