헤옹스 2022. 4. 8. 10:02

스트림 객체 : 자바에서 자료 처리를 추상화하여 여러 자료형의 자료를 동일하게 처리할 수 있도록 제공하는 클래스 (?)

스트림표현 방식 2가지

List<Book> bookList - new ArrayList<>();

bookList.add(new Book("자바", 25000));

bookList.add(new Book("파이썬", 15000));

bookList.add(new Book("안드로이드", 30000));

 

1) Stream <Book> bList = bookList.stream();

    bList.filter(b->b.getPrice() >= 2000).map(c->c.getName()).sorted().forEach(s-> System.out.println(s));

2) bookList.stream().filter(.........)....;