Java examples for java.lang:boolean
Convert String to Boolean value
public class Main { public static void main(String[] argv) { String b = "java2s.com"; System.out.println(toBool(b)); b = "false";//from www . ja v a 2 s .c o m System.out.println(toBool(b)); b = "true"; System.out.println(toBool(b)); b = "yes"; System.out.println(toBool(b)); } public static boolean toBool(String b) { try { return Boolean.parseBoolean(b); } catch (Exception e) { e.printStackTrace(); } return false; } }