Java Collection Tutorial - Java EnumMap(EnumMap < K ,? extends V > m) Constructor


EnumMap(EnumMap < K ,? extends V > m) constructor from EnumMap has the following syntax.

public EnumMap(EnumMap <K ,? extends V> m)


In the following code shows how to use EnumMap.EnumMap(EnumMap < K ,? extends V > m) constructor.

/*from   w  ww .j av  a 2s  . co m*/

import java.util.EnumMap;

enum Tutorial{CSS, Python, PHP, Java, Javascript}; 

public class Main {
   public static void main(String[] args) {
      EnumMap<Tutorial,String>  map = 
              new EnumMap<Tutorial,String> (Tutorial.class);

      EnumMap<Tutorial,String>  map1 =new EnumMap<Tutorial,String> (map);
      map.put(Tutorial.CSS, "1");
      map.put(Tutorial.Python, "2");
      map.put(Tutorial.Java, "4");

The code above generates the following result.