定义:
1 例子1:
public class MallConst {
public static final String CURRENT_USER = "currentUser";
public static final Integer ROOT_PARENT_ID = 0;
}
使用:
import static com.imooc.mall.consts.MallConst.ROOT_PARENT_ID;
if (category.getParentId().equals(ROOT_PARENT_ID)) {
CategoryVo categoryVo = new CategoryVo();
BeanUtils.copyProperties(category, categoryVo);
categoryVoList.add(categoryVo);
}
2 例子2:
private final static String CART_REDIS_KEY_TEMPLATE = "cart_%d";