Java Map create map from String to int array

Description

Java Map create map from String to int array

import java.util.HashMap;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    Map<String, int[]> h = new HashMap<String, int[]>();
    h.put("PID", new int[] { 1, 2 });
    h.put("XID", new int[] { 3, 4, 5, 6, 7 });

    System.out.println(h.get("PID")[0]); 
    System.out.println(h.get("XID")[1]); 
  }//from   ww  w.j a v a 2  s  .  c  o m
}



PreviousNext

Related