TreeMap的案例

package ditu.com;

import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;


public class TestTreeMap {
    public static void main(String[] args) {
    TreeMap<Integer,String> map=new TreeMap<Integer,String>();
        map.put(1, "andy");
        map.put(2, "bill");
        map.put(3, "cinaa");
        map.put(4, "davaid");
        map.put(6, "ella");
    SortedMap<Integer, String>    m=map.subMap(3, 10);
    
    //Set <Entry<Integer,String>>set=map.subMap(2, 6).entrySet();    
    Set <Entry<Integer,String>>set=m.entrySet();
        for(Entry<Integer,String> e:set){
            System.out.println(e);
        }
    
    }

}

 

posted @ 2017-05-09 19:08  苏轼的红烧肉  阅读(158)  评论(0编辑  收藏  举报