Java 8列表<V>到地图<K,V>
private Map<String, Choice> nameMap(List<Choice> choices) { final Map<String, Choice> hashMap = new HashMap<>(); for (final Choice choice : choices) { hashMap.put(choice.getName(), choice); } return hashMap;}
private Map<String, Choice> nameMap(List<Choice> choices) { return Maps.uniqueIndex(choices, new Function<Choice, String>() { @Override public String apply(final Choice input) { return input.getName(); } });}
private Map<String, Choice> nameMap(List<Choice> choices) { return Maps.uniqueIndex(choices, Choice::getName);}
浮云间
当年话下
慕田峪7331174
相关分类