W dniu 2012-04-04 03:54, Roedy Green pisze:
> I was looking over the table of contents of a book about new features
> in Java 7 and came across a reference to the "diamond operator".
>
> It turns out to be simple, but one of the precious bits of Java
> syntactic sugar to make it terser.
>
> http://fahdshariff.blogspot.ca/2011/...-operator.html
>
> http://mindprod.com/book/9781849685627.html
It will be better to provide "auto" type detector, like in C++.
For example, instead of:
Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
use:
auto map = new HashMap<Integer, List<String>>();
....and "map" variable will be resolved at compile time to
HashMap<Integer, List<String>>.
This allow very handy construct, like:
auto data = SomeService.getProviders();
In this case type of "data" will be deducted from return type of
SomeService.getProviders().
This will save lot of typing. And save refactoring time in case if
getProviders return type changes. And will auto-adapt to changes in
libraries.
--
Arivald