Java Map create from of method

Description

Java Map create from of method

import java.util.Map;

public class Main {

   public static void main(String[] args) {
      Map<Integer, String> players = Map.of(1, "Java", 2, "HTML", 3, "CSS", 4, "C");
      System.out.println(players.values());
      System.out.println("Player 2: " + players.get(2));

   }/*from   w w w  .java 2s .c  o m*/
}



PreviousNext

Related