Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java get keys from tree map

package com.java2novice.treemap;
 
import java.util.Set;
import java.util.TreeMap;
 
public class MyTreeMapKeys {
 
    public static void main(String a[]){
        TreeMap<String, String> hm = new TreeMap<String, String>();
        //add key-value pair to TreeMap
        hm.put("first", "FIRST INSERTED");
        hm.put("second", "SECOND INSERTED");
        hm.put("third","THIRD INSERTED");
        System.out.println(hm);
        Set<String> keys = hm.keySet();
        for(String key: keys){
            System.out.println(key);
        }
    }
}
Source by www.java2novice.com #
 
PREVIOUS NEXT
Tagged: #java #keys #tree #map
ADD COMMENT
Topic
Name
4+9 =