Write code to Parse string to Bool
//package com.book2s; public class Main { public static void main(String[] argv) { String source = "book2s.com"; boolean def = true; System.out.println(ParseBool(source, def)); }// ww w. j ava 2 s. c o m public static boolean ParseBool(String source, boolean def) { try { return Boolean.parseBoolean(source); } catch (NullPointerException e) { return def; } } }