The Boolean.valueOf() method returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE.
Java Boolean.valueOf() Method Example
public class BooleanClassExample {
public static void main(String[] args) {
valueOf();
}
private static void valueOf(){
// creating boolean variable
boolean b1 = true;
boolean b2 = false;
// getting Boolean objects from boolean variables
Boolean b3 = Boolean.valueOf(b1);
Boolean b4 = Boolean.valueOf(b2);
System.out.println(b3);
System.out.println(b4);
}
}
Output:
true
false
Reference
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course