Notes on implementing concise calls to constructors with type parameters
david.goodenough at linkchoose.co.uk
Thu May 14 02:20:59 PDT 2009
On Thursday 14 May 2009, Joseph D. Darcy wrote:
> Mark Derricutt wrote:
> > If you were going to use this syntax, why not be somewhat consistent with
> > the dynamic language folk and go for:
> > def foo = new ArrayList<String>();
> Java is not a dynamic language; I find declaring the full type on the
> left hand side (e.g. "List<String>") and initializing with the
> implementation type but without repeating the type parameter (e.g. "new
> ArrayList<>()") to be easy to read and more in keeping with the design
> of Java.
The logic of that suggests that in the case where you are instanciating a
new one of what is declared that one could use the notation:-
HashTable<String,Date> table = new;
which would imply:-
Hashtable<String,Date> table = new Hashtable<String,Date>();
Obviously is can not be done in the case of the lhs being Abstract, but in
that there is less repitition.
Maybe a step to far, but is removes another repeat.
> > Visually I find it more logical to read it this way.
> > On Thu, May 14, 2009 at 3:41 PM, Howard Lovatt
<howard.lovatt at iee.org>wrote:
> >> ArrayList<String> foo = new();
More information about the coin-dev