java 单键值对类AbstractMap.SimpleEntry使用方法

public class Test {
    public static void main(String[] args) {
        Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<String, String>("name", "野猿新一");
        System.out.println("new AbstractMap.SimpleEntry:" + entry);
        System.out.println("getKey:" + entry.getKey());
        System.out.println("getValue:" + entry.getValue());
        entry.setValue("野猿新二");
        System.out.println("setValue:" + entry);

    }
}

测试结果如下

new AbstractMap.SimpleEntry:name=野猿新一
getKey:name
getValue:野猿新一
setValue:name=野猿新二

 

posted @ 2019-05-18 22:30  野猿新一  阅读(44)  评论(0编辑  收藏  举报