Search
Calendar
June 2025
S M T W T F S
« May    
1234567
891011121314
15161718192021
22232425262728
2930  
Archives

Posts Tagged ‘diamond’

PostHeaderIcon Java 7 diamonds

Tiger (Java 5) introduced new syntax, among which generics are the most used. Mustang (Java 6) did not offer anything new. Dolphin (Java 7) will introduce a new scheme, the “diamond syntax”. We deal of diamond because of the look of theses characters: “<>

To sum up quickly, in Java 5 we have to write:

List<Integer>  myList = new ArrayList<Integer>()
Map<String, List<Double>> myMap = new Hashmap<String, List<Double>>();

On last Dolphin development releases, we can simply write:

Lis<Integer> myList = new ArrayList<>()
Map<String, List<Double>> myMap = new Hashmap<>();

There’s nothing revolutionary, but developpers will save a little more time ;-).