java后台实体类设置默认值


 private String orderPrice;//定义类的属性


/*
 * get set方法
 * String.trim()   返回字符串的副本,忽略前导空白和尾部空白。
 */
public String getOrderPrice() {
    if("".equals(orderPrice)||orderPrice==null){                        
        return "0";//去除该属性的前后空格并进行非空非null判断 
    }
       return orderPrice;
}

public void setOrderPrice(String orderPrice) {
     this.orderPrice = orderPrice == null ? null : orderPrice.trim();
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM