如果集合中的对象是string那么就不能使用funtion.indentity,针对string类型的集合就不能使用当前对象作为value吗
收起
如有帮助,请采纳呀!!!
List<String> demo = new ArrayList<>(); demo.add("1"); demo.add("2"); Map<String, String> collect = demo.stream().collect(Collectors.toMap(key -> key, value -> value)); System.out.println(collect);
报告相同问题?