我是Java流的新手,所以希望有人可以对此进行调试。我不明白我怎么得到最低的数字。
public class main {
public static void main(String[] args) {
Product p1 = new Product("1","name1",1000);
Product p2 = new Product("2","name2",2000);
Product p3 = new Product("3","name3",3000);
Product p4 = new Product("4","name4",4000);
HashMap<String,Product> map = new HashMap<String,Product>();
map.put(p1.getId(),p1);
map.put(p2.getId(),p2);
map.put(p3.getId(),p3);
map.put(p4.getId(),p4);
int i = (Integer) map.values().stream()
.map(x -> (Integer) Integer.valueOf(x.getId()))
.max(Integer::max).get();
System.out.println(i);
}
}