-
Enhancement
-
Resolution: Fixed
-
P3
-
5.0, 7
-
b72
-
generic, unknown, x86
-
generic, windows_xp
-
Verified
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<>();
- duplicates
-
JDK-4879776 Constructor type inference (JSR14 + JSR65 ++)
-
- Closed
-
- relates to
-
JDK-6894753 Diamond operator and anonymous class
-
- Closed
-
-
JDK-6880112 Project Coin: Port JDK core library code to use diamond operator
-
- Closed
-
-
JDK-5092426 (coll) Collections.newSet() etc to avoid redundancy and concrete types
-
- Closed
-
-
JDK-6242254 Language support for type inference
-
- Closed
-
-
JDK-6368076 Implicit typing of references via 'auto' keyword like upcoming C++ feature
-
- Closed
-
-
JDK-6939620 Switch to 'complex' diamond inference scheme
-
- Closed
-
-
JDK-6220689 Type arguments for a class shall be inferred on constructor invocation
-
- Closed
-
-
JDK-8061419 Typedef (alias)
-
- Closed
-