JAVA 1.5 New Features Dr V
The syntax of the enhanced for loop (for each) for (type variableName : arrayName) { statements } arrayName could be any collection object name (LinkedList, ArrayList, etc.)
Generics The syntax for specifying the type of elements in a collection CollectionClass collectionName = new CollectionClass (); A statement that creates an array list of type String ArrayList codes = new ArrayList (); A statement that creates an array list of integers ArrayList numbers = new ArrayList (); Code that creates a linked list of type Product LinkedList products; products = new LinkedList ();
Formatted Output System.out.println(“$%.2f”, amt); Prints $ for System.out.println(“%8.3f”, amt); Prints for