객체 스트림은 mapToInt, mapToLong 또는 mapToDouble 메서드를 이용해 기본 타입 스트림으로 변환할 수 있다. 예를 들어, 문자열 스트림에서 요소의 길이를 정수로 처리하려는 경우 IntStream으로도 수행할 수 있다.
Stream<String> words = ...;
IntStream lengths = words.mapToInt(String::length);
기본 타입 스트림을 객체 스트림으로 변환하려면 boxed 메서드를 사용한다.
Stream<Integer> integers = Integer.range(0, 100).boxed();