芝麻_糊

导航

String转换成Boolean类型

Boolean.valueOf()方法:

1  public static Boolean valueOf(String s) {
2         return toBoolean(s) ? TRUE : FALSE;
3     }

Boolean.toBoolean()方法

 private static boolean toBoolean(String name) {
        return ((name != null) && name.equalsIgnoreCase("true"));
    }

所以使用Boolean.valueOf(),当字符串不为空且字符串等于“true”(忽略大小写)返回true,否则为false

posted on 2017-09-12 17:00  芝麻_糊  阅读(1290)  评论(0编辑  收藏  举报