凡事都在事上磨,这样才能精进,成长进步提高! ------ 博客园首页

Map K-V互换

public static <K,V> HashMap<V,K> reverse(Map<K,V> map) {
return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));;
}

posted @ 2023-12-11 11:42  追风fc  阅读(31)  评论(0)    收藏  举报