package edu.xcdq.set;
import com.sun.org.apache.xerces.internal.impl.xs.models.XSCMUniOp;
import jdk.nashorn.internal.parser.JSONParser;
import java.util.HashSet;
/**
* @author yuhuicun
* @date 2021/5/8 9:17
*/
public class HashSetdemo {
public static void main(String[] args) {
HashSet<String> set = new HashSet<>();
set.add("111");
set.add("222");
set.add("333");
set.add("小明");
set.add("小华");
set.add("aaa");
set.add("bbb");
set.add("xxx");
System.out.println(set);
set.add("xxx");
System.out.println(set);
int size = set.size();
boolean empty = set.isEmpty();
System.out.println(set.parallelStream());
System.out.println(set);
}
}
import java.util.HashMap;
import java.util.Map;
/**
* @author yuhuicun
* @date 2021/5/8 10:07
*/
public class HashMapDemo {
public static void main(String[] args) {
HashMap<String,String> map = new HashMap<>();
map.put("henan","河南");// entry 实例
map.put("hebei","河北");
map.put("hubei","湖北");
map.put("hubei","湖北1");//键重复会覆盖掉原有的值
/*map.put("null","空");
map.put(null,"空2");
map.put(null,null);*/
System.out.println(map);
for (Map.Entry<String,String>m:map.entrySet()){
System.out.println(m);
}
for (String k : map.keySet()){
System.out.println(k+"="+map.get(k));
}
for (String v : map.values()){
System.out.println(v);
}
}
}