Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        // Using constructors
        Boolean b1True = new Boolean(true);
        Boolean b2True = new Boolean("true");
        Boolean b3True = new Boolean("tRuE");
        Boolean b4False = new Boolean("false");
        Boolean b5False = new Boolean("how  is this"); // false

        // Using the factory methods
        Boolean b6True = Boolean.valueOf(true);
        Boolean b7True = Boolean.valueOf("true");
        Boolean b8True = Boolean.valueOf("tRuE");
        Boolean b9False = Boolean.valueOf("false");
        Boolean b10False = Boolean.valueOf("how is this"); // false

        // Getting a boolean value from a Boolean object
        boolean bbTrue = b8True.booleanValue();

        boolean bTrue = Boolean.parseBoolean("true");
        boolean bFalse = Boolean.parseBoolean("This string evaluates to false");

        Boolean bcTrue = Boolean.TRUE;
        Boolean bcFalse = Boolean.FALSE;

        System.out.println("bcTrue = " + bcTrue);
        System.out.println("bcFalse = " + bcFalse);
    }
}