public class Animal {
private int id;
private String name;
}
List<Animal> list = new ArrayList<>();
list.add(new Animal(1, 'cat')));
list.add(new Animal(2, 'dog')));
list.add(new Animal(3, 'bird')));
Set<String> set = list.stream().map(Animal::getName).collect(Collectors.toSet()));
Map<Integer, Animal> map = list.stream().collect(Collectors.toMap(Animal::getId, Function.identity()));
Map<String, List<Animal>> map = list.stream().collect(Collectors.groupingBy(Animal::getName));
Map<String, List<Integer>> map = list.stream().collect(Collectors.groupingBy(Animal::getName, Collectors.mapping(Animal::getId, Collectors.toList())));
List<Integer> idList = list.stream().filter(it -> it.getId > 2).collect(Collectors.toList());
List<Animal> filterResult = list.stream().filter(it -> it.getId > 2).collect(Collectors.toList());
Animal an = list.stream().max(Comparator.comparing(Animal::getId)).get();
list.sort(Comparator.comparing(Animal::getId));