This project was built with Java 8 using IntelliJ IDEA.
This is a Maven project.
mvn exec:java -Dexec.mainClass="Playground"Execute in parallel, specifying number of threads.
mvn exec:java -Djava.util.concurrent.ForkJoinPool.common.parallelism=4 -Dexec.mainClass="Parallel"These will require Java 8+
javarepl
Objects.requireNonNull()
- Use this instead of doing manual null checks.
Playground.frequency(Collection c, Object o)
- Count number of occurrences of object in collection
UUID.randomUUID()
- Generate a random UUID for tests
Optional.ifPresent()
- Use a functional programming style and execute a block when object is present
https://dzone.com/articles/immutability-with-builder-design-pattern
stream()
A sequence of elements supporting sequential and parallel aggregate operations.
filter, map, sorted are intermediate operations, where forEach is terminal.
Streams may be iterated in parallel.
Collectors.groupingBy
Collectors.toMap
final ArrayList<String> list = new ArrayList(Arrays.asList("Ryan", "Julie", "Bob"));
final List a = new ArrayList(Arrays.asList(1,2,3));
ImmutableList.of(1, 2, 3);