2021
02-26
02-26
Java8 将一个List<T>转为Map<String,T>的操作
将List转为Map<String,T>publicclassAnswerApp{publicstaticvoidmain(String[]args)throwsException{List<String>names=Lists.newArrayList("Answer","AnswerAIL","AI");Map<String,Integer>map=names.stream().collect(Collectors.toMap(v->v,v->1));System.out.println(map);}}程序运行输出{Answer=1,AnswerAIL=1,AI=1}将List转为Map<K,V>publicstaticvoidmain(String[]args)thr...
继续阅读 >