JEP 186: Collection Literals
paul.sandoz at oracle.com
Tue Jan 14 06:22:22 PST 2014
On Jan 14, 2014, at 2:52 PM, Moshe Sayag <msayag at gmail.com> wrote:
> 1. What is the exact meaning of:
> List<Integer> list = #[ 1, 2, 3 ];
> Will 'list' be an ArrayList, a LinkedList or an immutable list?
It's an open question, there are many little details to be worked out, but here are some brief thoughts.
It could be the first or the third, unlikely to be the second (explicitly use LinkedList if that is required)
If the "target list type" is not a concrete type then the default could be an ArrayList , or it could be an immutable list whereby the implementation is chosen based on the number of elements (such rules do not need to be hardcoded by the platform if the mechanism is extensible e.g. there could be some annotation declared on List that describes what to do with the collection literal data).
I suspect that the third option might cause too many eyebrow raises (or WTFs!) to be viable, even though i like the concept (persistent collections anyone?).
More information about the lambda-dev