Write code to convert String value to Boolean using if statement to check
//package com.book2s; public class Main { public static void main(String[] argv) { String value = "true"; System.out.println(getBoolean(value)); }/*from w w w.ja v a 2 s . co m*/ public static boolean getBoolean(String value, boolean defaultValue) { boolean result = defaultValue; if ("true".equalsIgnoreCase(value) || "y".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value) || "1".equals(value) || "on".equalsIgnoreCase(value)) { result = true; } else if ("false".equals(value) || "n".equals(value) || "no".equalsIgnoreCase(value) || "0".equals(value) || "off".equalsIgnoreCase(value)) { result = false; } return result; } public static boolean getBoolean(String value) { return getBoolean(value, false); } }