首页 > 其他 > 详细

纠错本

时间:2014-12-22 22:35:02      阅读:319      评论:0      收藏:0      [点我收藏+]

关于Service中的赋值计算,利用三目运算符

注意:判断是"==",赋值是"="

    private Stipend getCountTotalize(Stipend e) {
        float count=0;
        count=count+(e.getBasic()==null?0:e.getBasic().longValue());
//        count=count+e.getBasic().longValue();
        count=count+(e.getDuty()==null?0:e.getDuty().longValue());
//        count=count+e.getDuty().longValue();
        count=count+(e.getEat()==null?0:e.getEat().longValue());
//        count=count+e.getEat().longValue();
        count=count+(e.getHouse()==null?0:e.getHouse().longValue());
//        count=count+e.getHouse().longValue();
        count=count+(e.getOther()==null?0:e.getOther().longValue());
        count=count-(e.getPunishment()==null?0:e.getPunishment().longValue());
        count=count-(e.getScot()==null?0:e.getScot().longValue());
        System.out.println("============================");
        System.out.println(count);
        e.setTotalize(new Float(count));
        return e;
    }

 

纠错本

原文:http://www.cnblogs.com/otio/p/4178975.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!