package Array.collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
public class map1 {
public static void main(String[] args) {
Map<String, Double> a=new HashMap<>();
a.put("合法化",236.3);
a.put("的发放",273.3);
a.put("芳芳",254.3);
a.put("啊我发",283.3);
//键找值
//获取键
Set<String> b = a.keySet();
//遍历全部键,获取全部值
for (String s : b) {
double c = a.get(s);
System.out.println(s + "======>" + c);
} //键值对
//调用MAp集合提供entrySet方法,吧map集合转换成键值对类型的set集合
Set<Map.Entry<String, Double>> entries = a.entrySet();
for (Map.Entry<String, Double> entry : entries) {
String key = entry.getKey();
Double value = entry.getValue();
System.out.println(key + "=====" + value);
}
a.forEach((u,i)-> {
System.out.println(u + "=======" + i);
});
a.forEach(new BiConsumer<String, Double>() {
@Override
public void accept(String u, Double i) {
}
});
}
}