📜  treemap java entryset - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:02.584000             🧑  作者: Mango

代码示例1
// 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 tree_map = new TreeMap();
  
        // 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());
    }
}