Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Creating Hashmap from Treemap

import java.util.HashMap;
import java.util.TreeMap;

class Main {
  public static void main(String[] args) {

    // create a treemap
    TreeMap<String, Integer> map = new TreeMap<>();
    map.put("Dog",1);
    map.put("Wolf",2);
    System.out.println("TreeMap: " + map+"
");

    // create hashmap from the treemap
    HashMap<String, Integer> map1 = new HashMap<>(map);
    map1.put("Leopard",3);
    System.out.println("HashMap: " + map1);
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: difference between final and constant in java 
Java :: zweidimensionales array erstellen java 
Java :: convert boolean to Boolean class 
Java :: configuration reader java 
Java :: set integer array value to null java 
Java :: Composite foreign keys as primary key jpa 
Java :: do i have to import files from the same package in java 
Java :: spring data rest id missing 
Java :: how to preset an array java 
Java :: Java Creating a LinkedHashMap 
Java :: dicom read with java 
Java :: java stream anymatch vs findany 
Java :: Java Protected Access Modifier package two 
Java :: jlabel text grösse 
Java :: wsl-allow-port 
Java :: copy array of objects in java 
Java :: java to run colored lines 
Java :: jsf prefix tag 
Java :: javafx how to put multiple handlers in the same line 
Java :: Child inside NestedScrollView not cover full height of screen 
Java :: diiferent ways to run spring boot 
Java :: bipredicate in java 
Java :: how to clear cli screen 
Java :: java tic tac toe gui based using applet 
Java :: TestNG Data Provider 
Java :: java lexographic 
Java :: how to return custom value in api spring boot 
Java :: java to kotlin online convertor 
Java :: click selectable in androiod 
Java :: how to print multi dimension array in java using for each loop 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =