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

public class Test {
    public static void main(String[] args) {
        Map.Entry entry = new AbstractMap.SimpleEntry("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=野猿新二

 

你可能感兴趣的:(Java,java,map,键值对,AbstractMap,SimpleEntry)