StreamEx 02-歪み外部リピータ
package day15;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class StreamEx02 {
public static void main(String[] args) {
List<Student> list = Arrays.asList(
new Student("aaa", 90),
new Student("bbb", 93),
new Student("ccc", 95)
);
double avg = list.stream() // 스트림 가져옴
.mapToInt(Student :: getScore) // 중간처리 : 학생 객체를 점수로 매핑
.average() // 최종처리 : 평균 구하기
.getAsDouble(); // 최종결과 리턴받기
System.out.println("평균 점수 : " + avg);
/*
Stream<Student> stream = list.stream();
stream.forEach(s -> {
String name = s.getName();
int score = s.getScore();
System.out.println(name + " : " + score);
});
*/
}
}
Reference
この問題について(StreamEx 02-歪み外部リピータ), 我々は、より多くの情報をここで見つけました https://velog.io/@jonny77/StreamEx02-Iterator-외부반복자テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol