JDK-6363651 : (coll) factory methods in collections classes to ease collection creation
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-15
  • Updated: 2017-06-03
  • Resolved: 2017-06-03
Related Reports
Duplicate :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
Creating new instances of generic collections can be very verbose.
e.g.
Map<Integer, FindMatchResults> resultsMap = new HashMap<Integer, FindMatchResults>();

Create factory methods in the various Collections subclasses that use capture to reduce the amount of typing, so I can go:

Map<Integer, FindMatchResults> resultsMap = HashMap.create();


JUSTIFICATION :
Simpler code is easier to read, write and debug.
Construction of new generic collections classes is extremely common, and the verbosity makes code harder to work with.

Comments
This is covered by JEP 269 (JDK-8048330). http://openjdk.java.net/jeps/269 It's also aided by the diamond "operator" added in Java 7.
03-06-2017