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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -