Last Updated: February 25, 2016
· ivolimmen

Convert Strings to objects in streams

You have a class called Word.

class Word {
   private String word;

   public Word(String word) {
      this.word = word;

You have a list of strings but need to work with Word objects.

List<String> list = Arrays.asList("A", "B", "C");

Create a stream of the list and use the map function: -> new Word(item));

When continuing with this line you have a Stream<Word> instance.