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

1
2
3
4
5
6
7
8
9
10
11
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);

}
}

Click and drag to move

测试结果如下

1
2
3
4
new AbstractMap.SimpleEntry:name=野猿新一
getKey:name
getValue:野猿新一
setValue:name=野猿新二

Click and drag to move