Skip to content

Instantly share code, notes, and snippets.

@activestudy
Created February 20, 2016 11:25
Show Gist options
  • Save activestudy/172c8c362a6e691238fd to your computer and use it in GitHub Desktop.
Save activestudy/172c8c362a6e691238fd to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StreamTest {
public static void main(String[] args) {
List<Person> people = new ArrayList<>();
people.add(new Person(18, "Joe"));
people.add(new Person(20, "Jack"));
people.stream()
.map(p -> p.getAge())
.peek(System.out::println) //(1)
.filter(age -> age < 20)
.peek(System.out::println); //thay forEach bằng peek (2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment