How do I convert a List in Java 8? -



How do I convert a List in Java 8? -

in java 8, can write

list<string> strlist = arrays.aslist("1", "2", "3"); list<integer> intlist = strlist.stream().map(s -> integer.valueof(s)).collect(collectors.tolist());

and pretty short already, have lots of these conversions , wonder why next not possible, i.e. why there no convert/transform method?

// won't work, list has no convert() or transform() method: list<integer> intlist = strlist.convert(s -> integer.valueof(s));

if implementation of convert clever, maybe lazy, conversion done when elements requested.

alternatively, of course of study write myself, maybe know library provides method?

// thought library provides util? list<integer> intlist = somelibraryutil.convert(strlist, s -> integer.valueof(s));

java

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -