package com.best.buc.verification.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Getter
@Setter
@AllArgsConstructor
public class Person {
private Integer id;
private String name;
public static void main(String[] args) {
List<Person> list = new ArrayList();
list.add(new Person(1, "1"));
// list.add(new Person(1, "4"));
list.add(new Person(2, "2"));
list.add(new Person(3, "3"));
Map<Integer, Person> collect = list.stream().collect(Collectors.toMap(Person::getId, Function.identity()));
Map<Integer, Person> collect1 = list.stream().collect(Collectors.toMap(Person::getId, Function.identity(), (a,b)->a));
Map<In
Stream流Collectors.toMap用法
最新推荐文章于 2025-04-29 11:46:59 发布