-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashMap08_6_1.java
More file actions
28 lines (23 loc) · 1.12 KB
/
HashMap08_6_1.java
File metadata and controls
28 lines (23 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//import java.io.*;
import java.util.*;
class HashMap08_6_1
{
public static void main (String[] args) throws java.lang.Exception
{
//HashMap 实现map, 内置类的条目 Entry子类; 其value 为null时候,其实就是Set类;
// HashMap的实现、put、remove + - 查询 和遍历操作;
Map pengBookHM = new HashMap();
pengBookHM.put("2015","DigitalComm");
pengBookHM.put("2015.10","WirelessComm");
pengBookHM.put("2019","DeepLearning");
pengBookHM.put("2019.7","Mxnet");
pengBookHM.replace("2019.7","MxNet Best NN");
System.out.println(pengBookHM);
pengBookHM.merge("2019","New",(oldVal, param)-> ((String)oldVal).length()+((String)param).length());
System.out.println(pengBookHM);
pengBookHM.computeIfPresent("2015",(key,value)->( ( (String)key).concat((String)value)));
pengBookHM.merge("2019.7","New",(v1, param)-> ((String)v1).concat(((String)param)));
System.out.println(pengBookHM);
pengBookHM.forEach((key,value)-> System.out.println(key+"->"+value));
}
}