if (pstr==null) return dvalue;
习惯这么写的路过:
if (pstr==null) {
return dvalue;
}

解决方案 »

  1.   

    什么怎么看?是问alert怎么写?要写给浏览器你得拿到response
      

  2.   

    1、所有的if我会加大括号。
    2、大括号不喜欢你那种风格。
    3、""和null判断直接一次可以判断不需要分2次
      

  3.   

    3、直接用StringUtils(自己封装或者用apache的都行)
      

  4.   

    这个就是将字符串转成int,如果发生异常或字符串为空串返回第二个参数默认值。没啥看法
      

  5.   

    alter怎么写是在js中的 ,楼主这么屌,你家里人知道吗
      

  6.   

    public int toInt(String str, int defaultVal) {
    try {
    return Integer.parseInt(str);
    } catch (Exception e) {
    }
    return defaultVal;
    }
    我一般这么写
      

  7.   

    原来这样写就可以,学习了,谢谢
    这样是可以实现,但是实际开发中catch语句中最好不要出现空语句,另可加上e.printStackTrace();
    public int toInt(String str, int defaultVal) {
    int i;
    try {
    i = Integer.parseInt(str);
    } catch (Exception e) {
    i = defaultVal;
    }
    return i;
    }
    感觉这样会好理解点
      

  8.   

    原来这样写就可以,学习了,谢谢
    这样是可以实现,但是实际开发中catch语句中最好不要出现空语句,另可加上e.printStackTrace();
    public int toInt(String str, int defaultVal) {
    int i;
    try {
    i = Integer.parseInt(str);
    } catch (Exception e) {
    i = defaultVal;
    }
    return i;
    }
    感觉这样会好理解点
    看具体情况了,有的时候我会加上debug日志,至于catch里面不要空语句,看个人习惯或者开发要求了。
      

  9.   


    Java规范是你那样写的我习惯左右{}在竖直方向上对齐还好不是和人家SVN合作,否则就悲剧了