In reality, this is just a short cut for a simpler type inference for generic instance creation.
So instead of this:
List<String> stringList = new ArrayList>String>();
one can use this in Java7:
List<String> stringList = new ArrayList<>();
So you say "big deal"?! The real benefits show when the type being inferred is very complicated and has multiple types nested in it like:
Map<String, List<Pair<String,BigDecimal>> myMap = new HashMap<>();
You are saved from repeating the same thing - less typing and less errors!
No comments:
Post a Comment