반응형

 

 

예제 소스코드: HashMap

import java.util.HashMap;

class Main {
  public static void main(String[] args) {
    // create an HashMap
    HashMap<String, Integer> prices = new HashMap<>();

    // insert entries to the HashMap
    prices.put("Shoes", 200);
    prices.put("Bag", 300);
    prices.put("Pant", 150);
    System.out.println("HashMap: " + prices);

    // return view of all values
    System.out.println("Values: " + prices.values());
  }
}

출력화면

HashMap: {Pant=150, Bag=300, Shoes=200}
Values: [150, 300, 200]

 

 

 

 

반응형