<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/94dbaed9-349c-449d-bc43-25de3ae5a780/SpartaIconScale9.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/94dbaed9-349c-449d-bc43-25de3ae5a780/SpartaIconScale9.png" width="40px" /> 수업 목표

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/393cd135-1603-4797-8fa6-42abcfedd782/SpartaIconS24.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/393cd135-1603-4797-8fa6-42abcfedd782/SpartaIconS24.png" width="40px" />

목차

</aside>

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/11965e36-5cde-4d10-b470-06dfbe247327/scc캐릭터_아하_280x280.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/83c75a39-3aba-4ba4-a792-7aefe4b07895/11965e36-5cde-4d10-b470-06dfbe247327/scc캐릭터_아하_280x280.png" width="40px" /> 필수 프로그램 설치

프로그램 설치가이드를 따라 천천히 설치를 진행해주세요.

✅ OpenJDK 8버전 이상

✅ IntelliJ (Community)

✅ Google Chrome

</aside>


학습 키워드 점검


스트림(stream) 이란?

<aside> 📚

스트림이 무엇인지 알아봅시다.

</aside>

비교해보기(for vs 스트림)

<aside> 💡

각 요소를 10배로 변환 후 출력하는 예시로 알아봅시다.

List<Integer> arrayList = new ArrayList<>(List.of(1, 2, 3, 4, 5));
public class Main {

    public static void main(String[] args) {

        // ArrayList 선언
        List<Integer> arrayList = new ArrayList<>(List.of(1, 2, 3, 4, 5));

        // ✅ for 명령형 스타일: 각 요소 * 10 처리
        List<Integer> ret1 = new ArrayList<>();
        for (Integer num : arrayList) {
            int multipliedNum = num * 10; // 각 요소 * 10
            ret1.add(multipliedNum);
        }
        System.out.println("ret1 = " + ret1); 
    }
}

public class Main {

    public static void main(String[] args) {

        // ArrayList 선언
        List<Integer> arrayList = new ArrayList<>(List.of(1, 2, 3, 4, 5));

        // ✅ 스트림 선언적 스타일: 각 요소 * 10 처리
        List<Integer> ret2 = arrayList.stream().map(num -> num * 10).collect(Collectors.toList());
        System.out.println("ret2 = " + ret2);
    }
}

<aside> ❗

ArrayList 를 List 로 받는 이유

List<Integer> arrayList = new ArrayList<>();

</aside>

</aside>


스트림 살펴보기(선언형 스타일)

<aside> 📚

스트림 처리 단계를 살펴봅시다.

단계 설명 주요 API
1. 데이터 준비 컬렉션을 스트림으로 변환 stream(), parallelStream()
**2. 중간 연산 등록
(즉시 실행되지 않음)** 데이터 변환 및 필터링 map(), filter(), sorted()
3. 최종 연산 최종 처리 및 데이터 변환 collect(), forEach(), count()
</aside>