, :
mylist
.stream()
.map(variant -> variant.getSku())
.collect(Collectors.toCollection(ArrayList::new)))
As an initial structure, if you use arrays instead of collections, go from myList.streamto Stream.of(variantArray).map().
As for your final structure, adjust if ArrayList::newyou need HashSet ( HashSet::new) or linked list ( LinkedList::new) instead
and if you have many different options, and you want to quickly and quickly assemble them Skus, consider parallel processing of the stream, adding parallel()to the function stream():
mylist
.stream()
.parallel()
.map(variant -> variant.getSku())
source
share