Advertisement
ivana_andreevska

HashMap Basic

Dec 23rd, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.util.HashMap;
  2.  
  3. public class HashMapAwesomeness {
  4.     public static void main(String[] args) {
  5.         int a=10;
  6.         int b=3;
  7.         int c=88;
  8.  
  9.         HashMap<String,Integer> happy=new HashMap<String,Integer>();
  10.         //left side is key and right side is what is stored in it
  11.  
  12.         happy.put("a",10);
  13.         happy.put("b",3);
  14.         happy.put("c",88);
  15.  
  16.         System.out.println(happy);
  17.         System.out.println(happy.get("c"));
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement