【JAVA 8】stream操作リスト内のエンティティリストのいずれかの属性Setを個別に取り出す


public static void main(String[] args) {
            List stuList = new ArrayList<>();
            stuList.add(new Stu("  ", 3));
            stuList.add(new Stu("  ", 4));
            Set nameSet = stuList.stream().collect(HashSet::new,
            (s, stu) -> { s.add( stu.name ); }, (s1, s2) ->{ s1.addAll(s2); });
            System.out.println(nameSet);
    }

static class Stu{
    String name;
    int age;
    Stu(String name, int age){
        this.name = name;
        this.age = age;
    }
}

        :[  ,   ]

    collect    :
/**
 * @param        
 * @param supplier          
 * @param accumulator       
 * @param combiner        
 */
 R collect(Supplier supplier,
              BiConsumer accumulator,
              BiConsumer combiner);