Re: Idea to Java ArrayLists

2015-07-16 Thread Stuart Marks
On 7/9/15 9:21 AM, Remi Forax wrote: There is an open bug to add a bunch of static methods 'of' to do something similar to what you want, https://bugs.openjdk.java.net/browse/JDK-8026106 this is something that a lot of people will like to have and i hope that this can be integrated in 9. H

Re: Idea to Java ArrayLists

2015-07-10 Thread Paul Sandoz
Hi Philipp, This area has been the subject of much discussion over the years. Previously we investigated the idea of collection literals in the following research JEP: http://openjdk.java.net/jeps/186 See discussion on lambda-dev: http://mail.openjdk.java.net/pipermail/lambda-dev/2014-Ja

Re: Idea to Java ArrayLists

2015-07-09 Thread Staffan Friberg
On 07/09/2015 01:10 PM, Pavel Rappo wrote: On 9 Jul 2015, at 20:46, Remi Forax wrote: just to be complete , there is also ArrayList l = new ArrayList<>(); Collections.addAll(l, "1", "2", "3", "4", "5"); which avoid the allocation of the intermediary list. Thanks Remi, I forgot about t

Re: Idea to Java ArrayLists

2015-07-09 Thread Pavel Rappo
> On 9 Jul 2015, at 20:46, Remi Forax wrote: > > just to be complete , there is also > > ArrayList l = new ArrayList<>(); > Collections.addAll(l, "1", "2", "3", "4", "5"); > > which avoid the allocation of the intermediary list. Thanks Remi, I forgot about that. That's arguably the next b

Re: Idea to Java ArrayLists

2015-07-09 Thread Remi Forax
On 07/09/2015 09:05 PM, Pavel Rappo wrote: On 9 Jul 2015, at 18:46, Louis Wasserman wrote: what you can do there is new ArrayList<>(Arrays.asList("1", "2", "3", "4", "5")); Louis, sure we can do this. No problem with that. But what we are really talking about here (as far as I understand) i

Re: Idea to Java ArrayLists

2015-07-09 Thread Pavel Rappo
> On 9 Jul 2015, at 18:46, Louis Wasserman wrote: > > what you can do there is new ArrayList<>(Arrays.asList("1", "2", "3", "4", > "5")); Louis, sure we can do this. No problem with that. But what we are really talking about here (as far as I understand) is a convenience. In my opinion there'

Re: Idea to Java ArrayLists

2015-07-09 Thread kedar mhaswade
Yeah, or LinkedList strings = new LinkedList<>(Arrays.asList("1", "2", "3")); But I guess what Phillip really wants is to be able to *express* ArrayList strings = ["1", "2", "3"]; and I believe there's a reason he can't have it :-( On Thu, Jul 9, 2015 at 10:46 AM, Louis Wasserman wrote: > Pavel

Re: Idea to Java ArrayLists

2015-07-09 Thread Daniel Fuchs
Or Stream.of("1", "2", "3").collect(Collectors.toList()); :-) -- daniel On 09/07/15 19:46, Louis Wasserman wrote: Pavel, what you can do there is new ArrayList<>(Arrays.asList("1", "2", "3", "4", "5")); On Thu, Jul 9, 2015 at 10:40 AM Pavel Rappo wrote: Not quite. You don't have the abilit

Re: Idea to Java ArrayLists

2015-07-09 Thread Pavel Rappo
Not quite. You don't have the ability to specify a particular implementation (e.g. the thing won't work if what you want is, say, LinkedList) > On 9 Jul 2015, at 18:34, kedar mhaswade wrote: > > Wouldn't Arrays.asList >

Re: Idea to Java ArrayLists

2015-07-09 Thread kedar mhaswade
Philipp, Wouldn't Arrays.asList work for you? e.g. List strings = Arrays.asList("1", "2", "3"); or List strings = Arrays.asList("1", "2", "3", "4", "five"); Regards, Kedar On Thu, Jul 9, 2015 at 8:55 AM, Philipp Bibik

Re: Idea to Java ArrayLists

2015-07-09 Thread Martin Buchholz
Many people have thought about this kind of thing, but it's complicated. Many people regret having java constructors (instead of factory methods). Many people regret how varargs worked out, because generics and arrays don't mix well. Many people think java should have List and Map literals. See how

Re: Idea to Java ArrayLists

2015-07-09 Thread Remi Forax
Hi Philipp, there is an issue with your proposal, with ArrayList list = new ArrayList<>(1); and ArrayList list = new ArrayList<>(1, 2); the first line will create an empty array list, the integer will be used to define the capacity of the list, the second line will create a list with two v