Le 02/02/2010 17:26, Ulf Zibis a écrit :
Am 02.02.2010 14:30, schrieb Rémi Forax:
Le 02/02/2010 14:09, Ulf Zibis a écrit :
Hi,

in most cases you use the empty diamond operator '<>' on instantiation, but not for SoftReference: "new SoftReference<Charset>(cs)" in AbstractCharsetProvider.java
Why?

SoftReference constructor is SoftReference(T), so there is two ways to infer the type argument.

With this code:
SoftReference<Charset> ref = new SoftReference<>(cs);
the type argument can be infered from the lhs of the assignation or
by the declared type of the parameter (here cs).


So you agree with me, that new SoftReference<>(cs) would suffice ???

No.
The code is:

cache.put(csn, new SoftReference<Charset>(cs));


It will not compile, because Object will be infered.
Diamond doesn't take care about method's parameter types
(Maurizio correct me if I'm wrong)



-Ulf


Rémi

Reply via email to