我正在研究功能,我已经尝试过了
Function<Person,String> byName = Person::getName;
System.out.println( byName.apply(list.get(1)) );
这有效并在索引 1 处打印了该人的姓名;
但现在我想创建Function<List<Person>,String>以遍历列表中的所有人
Function<List<Person>,String> allNames = a -> a.forEach(e-> e.getName());
System.out.println(allNames.apply(list));
它抛出一个错误,因为“void cannot be converted to String”
 慕哥6287543
慕哥6287543 
					qq_笑_17
 
					富国沪深
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类