JavaStudy.zip
立即下载
资源介绍:
JavaStudy.zip
package com.ww.setPractice;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class setDemo {
public static void main(String[] args) {
HashMap map = new HashMap<>();
map.put("lww","lyy");
map.put("fjw","tyj");
map.put("gax","ff");
Set keys = map.keySet();
Iterator it = keys.iterator();
while (it.hasNext()){
String key = it.next();
System.out.println(key + " " + map.get(key));
}
System.out.println("=================");
map.forEach((String s, String s2)-> {
System.out.print(s+" ");
System.out.println(s2);
}
);
System.out.println("=================");
keys.forEach(new Consumer() {
@Override
public void accept(String s) {
System.out.println(s+" " + map.get(s));
}
});
System.out.println("=================");
for (String key : keys) {
String value = map.get(key);
System.out.println(key + value);
}
System.out.println("=================");
Set> set = map.entrySet();
for (Map.Entry entry : set) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
System.out.println("====ddd=========");
set.forEach((Map.Entry stringStringEntry)-> {
System.out.println(stringStringEntry.getKey() + " " + stringStringEntry.getValue());
}
);
}
}