Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

hashmap put method

import java.util.HashMap;

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

    // insert items to the HashMap
    languages.put("Java", 14);
    languages.put("Python", 3);
    languages.put("JavaScript", 1);

    // display the HashMap
    System.out.println("Programming Languages: " + languages);
    }
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #hashmap #put #method
ADD COMMENT
Topic
Name
5+4 =