All About Class Boolean in Java

0
102
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

Class Boolean in Java
Class Boolean in Java

Class Boolean in Java

Class Boolean in Java:

This class allows coder to define primitive type Boolean for an object. An object of type boolean can contain a single filed whose type is boolean.The Boolean class provides an object Wrapper for a boolean value. It is very useful when we need to treat boolean value as an object.The Boolean class supports to implement Reflection API and class literals.

Below is the Structure of Boolean class:


public final class java.lang.Boolean extends java.lang.Object{
//Member elements of the Boolean class
public final static Boolean FALSE;
//A constant Boolean object whose's value is FALSE
public final static Boolean TRUE;
//A constant Boolean object whose's value is TRUE
public final static Class TYPE; 
//The Class object that represents the type boolean. It is always true if
//Boolean.TYPE==boolean.class.
//constructors:
public Boolean(boolean value);
// creates a Boolean object initialized with the value provided as an argument.
public Boolean(String Str);
//Creates a Boolean object initialize with the value TRUE if the String argument
//provided is not null and is equals to ignore case to the String //"True", Otherwise
//creates a boolean object initialized as false.
//Methods:
public boolean booleanValue();
//This method returns the boolean value of an object.
public boolean equals(Object obj);
//This method returns true if the obj is an instance of Boolean and it contains the 
//same value as the object this method is associated with.
public static boolean getBoolean(Sting str);
//this method returns the boolean value of the named system property.
public int hashcode();
//Returns the hashcode based on the boolean value of object.
public String toString();
//This method returns "true" if the value of the object is true. Otherwise it returns false.
//Basically a String representation of the object.
public static Boolean valueOf(String s);
//This method returns Boolean object with the value TRUE if the String argument
//provided is not null and is equals to ignore case to the String //"True", Otherwise
//returns a boolean object whose value is false.
}
 

Apart from these this class also has the below inherited methods:
From Object class

  • clone()
  • getClass()
  • equals(Object obj);
  • finalize()
  • notify()
  • notifyAll()
  • wait()
  • wait(long timeput)
  • wait(long timeout,int nanos)
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here