List의 요소가 null일 때
목록 설명 List<Integer> list = List.of(23,46,24,68,null); //NullPointerException Error 먼저 List.of를 사용하여 숫자 예제로 목록을 만들었습니다. NullPoint 오류가 계속 발생하여 확인했습니다. List.of() 메소드는 목록은 null 값을 포함할 수 없습니다… null 값을 포함하는 예제 목록을 생성하려는 경우 배열.asList()사용해야 List<Integer> list = Arrays.asList(23,46,24,68,null); 1) 삼항 연산자를 사용한 방법 list.stream() .map(i->i==null?0:i) .forEach(System.out::println); 2) 선택적 개체가 있는 메서드 – 값이 … Read more