Online Java Compiler By
JavaTpoint.com
public class JavaBooleanExample2 { public static void main(String[] args) { Boolean b1 = true; System.out.println("Boolean value = " + b1); //prints the hash code of the boolean value System.out.println("Hash Code for boolean value = " + b1.hashCode()); //converting boolean value tp String String str = b1.toString(); System.out.println("String value = " + str); System.out.println("Hash Code for String Value = " + str.hashCode()); // will return a boolean instance corresponding to Boolean b1 Boolean b2 = Boolean.valueOf(b1); System.out.println("valueOf() method will return = " + b2); boolean val1 = false; for (int i = 0; i < 10; i++) { if (i == 5) { System.setProperty("val1", "true"); break; } } boolean b3 = Boolean.getBoolean("val1"); System.out.println("value of val is " + b3); } }
Output