Java Map Invert invert(Map map)

Here you can find the source of invert(Map map)

Description

Inverts the values of a list.

License

Open Source License

Parameter

Parameter Description
map a parameter
A a parameter
B a parameter

Declaration

public static <A, B> Map<B, A> invert(Map<A, B> map) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**/*from  w  w w .  ja v a 2  s  .  c  o  m*/
     * Inverts the values of a list.
     * @param map
     * @param <A>
     * @param <B>
     * @return
     */
    public static <A, B> Map<B, A> invert(Map<A, B> map) {
        Map<B, A> map1 = new HashMap<>();
        map.forEach((k, v) -> map1.put(v, k));
        return map1;
    }
}

Related

  1. inverse(Map m, Map newMap)
  2. inverse(Map map)
  3. inverse(Map map)
  4. inverseGet(Map map, Object value)
  5. invert(Map in)
  6. invert(Map map)
  7. invert(Map map, String prefix)
  8. invert(Map map)