Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

In this page you can find the example usage for java.lang Boolean valueOf.

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:Main.java

public static void main(String[] args) {
    Boolean b = Boolean.valueOf("true");
    System.out.println(b.toString());
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Boolean.valueOf("true"));
}

From source file:MainClass.java

public static void main(String[] args) {
    Boolean b = Boolean.valueOf("true");
    System.out.println(b);
}

From source file:Main.java

public static void main(String[] args) {
    boolean b = true;
    Boolean bool = Boolean.valueOf(b);
    System.out.println("bool = " + bool);

    if (bool.equals(Boolean.TRUE)) {
        System.out.println("bool = " + bool);
    }// w  w  w  .  j  a  v a 2 s  . c  o m

    String s = "false";

    Boolean bools = Boolean.valueOf(s);
    System.out.println("bools = " + bools);

    String f = "abc";
    Boolean abc = Boolean.valueOf(f);
    System.out.println("abc = " + abc);
}

From source file:Main.java

public static void main(String[] args) {
    boolean bool1 = true;
    boolean bool2 = false;
    Boolean b1 = Boolean.valueOf(bool1);
    Boolean b2 = Boolean.valueOf(bool2);

    System.out.println(b1);//  w  w  w.  j a va  2  s  .c  om
    System.out.println(b2);
}

From source file:MainClass.java

public static void main(String args[]) {

    Boolean bool = Boolean.valueOf("true");
    Character c = new Character('c');
    Byte b = Byte.valueOf("12");
    Short s = Short.valueOf("2");
    Integer i = Integer.valueOf("13245");
    Long l = Long.valueOf("12341234");
    Float f = Float.valueOf("11234.1234");
    Double d = Double.valueOf("43213241234.123412341234");

    System.out.println(bool);//w w  w. ja v a2 s  .c  o  m
    System.out.println(c);
    System.out.println(b);
    System.out.println(s);
    System.out.println(i);
    System.out.println(l);
    System.out.println(f);
    System.out.println(d);
}

From source file:Main.java

public static void main(String[] args) {
    boolean b = true;
    // using constructor
    Boolean blnObj1 = new Boolean(b);
    // using valueOf method of Boolean class. 
    Boolean blnObj2 = Boolean.valueOf(b);
}

From source file:Main.java

public static void main(String[] args) {
    String str = "false";
    // Convert using constructor
    Boolean blnObj1 = new Boolean(str);
    System.out.println(blnObj1);/*w  w w .j av a 2s.  co  m*/

    // Use valueOf method of Boolean class. This is a static method.
    Boolean blnObj2 = Boolean.valueOf(str);
    System.out.println(blnObj2);
}

From source file:Main.java

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);
}

From source file:samples.ConsumerApplication.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    context.registerShutdownHook();//w ww .  j  a v a  2 s. c o  m

    boolean sync = true;
    if (args != null && args.length > 0) {
        sync = Boolean.valueOf(args[0]);
    }

    if (sync == true) {
        //Example of a sync consumer with Spring JMS
        SpringJmsConsumer consumer = (SpringJmsConsumer) context.getBean("springJmsConsumer");
        consumer.run();
        ((org.springframework.jms.connection.CachingConnectionFactory) context.getBean("connectionFactory"))
                .resetConnection();
    } else {
        //Example of an async consumer with Spring JMS (autoStartup is normally set to true)
        AbstractJmsListeningContainer listenerContainer = (AbstractJmsListeningContainer) context
                .getBean("listenerContainer");
        listenerContainer.start();
    }
}