자바 Stream을 이용한 타입별 형 변환
Stream이란? 자바8부터 지원하는 Stream은 컬렉션, 배열등에 저장되어있는 요소들을 하나씩 참조하여 반복적인 처리를 가능케 하는 기능이다. 아래 코드를 통하여 간단하게 Stream을 이용한 타입별 형 변환을 알아보자. public class 형변환 { @Test public void main(){ List list = new ArrayList(); list.add(1); list.add(2); list.add(3); //list To int[] int[] ints = list.stream().mapToInt(m -> m).toArray(); //list To String[] String[] strings = list.stream().map(String::valueOf).toArray(String[..