Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
One of the language changes in Project Coin is allowing inference on constructor call through the <> notation (aka 'diamond'); this bug tracks that work. SUMMARY OF THE PROPOSAL This proposal addresses the addition of limited type inference for class instance creation expressions to the Java programming language. In cases where parametrized types need to be explicitly declared for a constructor, and the full parametrized type < T1 , T2 , ...Tn > of that constructor is obvious from the context, then the parameterized type of the constructor can be replaced with an empty set of type parameters: <>. The <> construct is legal to use when constructing an ob ject and either assigning it to a variable, or when passing it as a parameter. For example, consider the following assignment statement: Map<String, List<String>> anagrams = new HashMap<String, List<String>>(); This is rather lengthy, so it can be replaced with this: Map<String, List<String>> anagrams = new HashMap<>();
|