Skip to content

Instantly share code, notes, and snippets.

@yrashish
Created December 30, 2020 17:26
Show Gist options
  • Save yrashish/d33b48bb0cdfbfb4af131bb5ffe833ef to your computer and use it in GitHub Desktop.
Save yrashish/d33b48bb0cdfbfb4af131bb5ffe833ef to your computer and use it in GitHub Desktop.
var employees = Arrays.asList(new Employee(1, "Ashish", 28, 10000)
, new Employee(2, "Ajay", 29, 1000)
, new Employee(3, "Abhishek", 29, 10000));
var employeeMap = employees.stream()
.collect(Collectors.toMap(Employee::getId, Employee::getName));
var groupedMap = employees.stream()
.collect(Collectors.groupingBy(Employee::getSalary));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment