Chọn tất cả đáp án đúng: thao tác nào là terminal operation của Stream?
Xem đáp án và giải thích
Intermediate operation (map, filter, sorted, distinct, peek...) trả về Stream và chỉ ghi nhận thao tác. Terminal operation (collect, forEach, reduce, count, findFirst, toList...) mới thực sự chạy pipeline và sau đó stream không dùng lại được nữa. Gọi terminal thứ hai trên cùng stream sẽ ném IllegalStateException.