Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

treemap java entryset

// Java code to illustrate the entrySet() method
import java.util.*;
  
public class Tree_Map_Demo {
    public static void main(String[] args)
    {
  
        // Creating an empty TreeMap
        TreeMap<Integer, String> tree_map = new TreeMap<Integer, String>();
  
        // Mapping string values to int keys
        tree_map.put(10, "Geeks");
        tree_map.put(15, "4");
        tree_map.put(20, "Geeks");
        tree_map.put(25, "Welcomes");
        tree_map.put(30, "You");
  
        // Displaying the TreeMap
        System.out.println("Initial Mappings are: " + tree_map);
  
        // Using entrySet() to get the set view
        System.out.println("The set is: " + tree_map.entrySet());
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #treemap #java #entryset
ADD COMMENT
Topic
Name
8+7 =