Stream流式计算
首先创建一个商品类
包含以下属性:
1.商品id;
2.商品名name;
3.商品类型type;
4.商品价格price;
5.库存量stock;
6.月销量sales;
7.上架时间time;
Goods类:
package com.peng.lesson23.lianxi;
import java.util.Date;
public class Goods {
private int id;
private String name;
private String type;
private int price;
private int stock;
private int sales;
private Date time;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public double getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public double getSales(