I need to fill an ArrayList with some (random) data. I wonder if Java 8/9 allows a more concise way than this:
List list = new ArrayList();
for (int ii=0;ii<100;ii++)
list.add(UUID.randomUUID().toString());
Thanks!
I need to fill an ArrayList with some (random) data. I wonder if Java 8/9 allows a more concise way than this:
List list = new ArrayList();
for (int ii=0;ii<100;ii++)
list.add(UUID.randomUUID().toString());
Thanks!
Probably this will do:
Supplier<String> supplier = () -> UUID.randomUUID().toString();
List<String> list = Stream.generate(supplier).limit(100).collect(Collectors.toList());