Java Collection Tutorial - Java EnumMap.values()


EnumMap.values() has the following syntax.

public Collection <V> values()


In the following code shows how to use EnumMap.values() method.

//from w  ww . j a  va  2s  .  c  om
import java.util.*;

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);

      map.put(Tutorial.CSS, "1");
      map.put(Tutorial.Python, "2");
      map.put(Tutorial.PHP, "3");
      map.put(Tutorial.Java, "4");


      Collection<String>  values = map.values();

      System.out.println("Collection:" + values);

The code above generates the following result.