Skip to content

Instantly share code, notes, and snippets.

@Karm
Created March 18, 2019 08:09
Show Gist options
  • Save Karm/d8605241f088f6f72d6334588510f77f to your computer and use it in GitHub Desktop.
Save Karm/d8605241f088f6f72d6334588510f77f to your computer and use it in GitHub Desktop.
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
private static Map<Integer, String> jobs = new HashMap<Integer, String>() {
{
IntStream.range(0, 100).forEach(n -> put(n, "Something "+n));
}
};
public static void main(String[] args) {
jobs.entrySet().stream().filter(x -> x.getKey() > 5).collect(Collectors.toList()).forEach(e -> System.out.println(e.getValue()));
//jobs.entrySet().stream().filter(x -> x.getKey() > 5).collect(Collectors.toSet()).forEach(e -> System.out.println(e.getValue()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment