Map<Car, Integer> map = new HashMap<Car, Integer>();
map.put(new Car("black", "benz"), 1);
map.put(new Car("black", "benz"), 2);
map.put(new Car("black", "BMW"), 2);
map.put(new Car("red", "benz"), 2);
for(Entry<Car, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey().getBrand());
}
System.out.println("~~~~~~~~~~~~~~~");
map.forEach((Car k,Integer v) ->
System.out.println(k.getBrand() + " " + v));
后面的lamdba哪里错了啊,运行就报错
onemoo
相关分类