Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Boolean Wrapper Class

Posted By: Kenny Moore     Category: Java     Views: 27726

This article explains about Boolean wrapper class in java.

Boolean wrapper class is used to wrap primitive data type boolean value in an object. 

Examples of Boolean Wrapper Class

Example 1 : Convert Boolean Object to boolean data type

public class BooleanToboolean
  public static void main(String[] args) 
    Boolean bObj = new Boolean("true");
    boolean b = bObj.booleanValue();

This example show how a Boolean object can be converted to a boolean data type.

Example 2 : Convert String Object to Boolean Object

public class StringToBoolean 
  public static void main(String[] args) 
    String str = "true";
    Boolean bObj1 = new Boolean(str);
    Boolean bObj2 = Boolean.valueOf("false");

This example shows how to convert String object to a Boolean object.


Didn't find what you were looking for? Find more on Boolean Wrapper Class Or get search suggestion and latest updates.

Kenny Moore
Kenny Moore author of Boolean Wrapper Class is from Columbus, United States.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!