Java autoboxing unboxing Boolean Values

Introduction

Java Boolean is wrapper class for boolean.

Java Autoboxing/unboxing applies to Boolean objects.

public class Main { 
  public static void main(String args[]) { 
    /*from  ww  w  . j  a  v a 2s .c o m*/
    // Autobox/unbox a boolean. 
    Boolean b = true; 
 
    // b is auto-unboxed when used in  
    // if conditional expression
    if(b) 
       System.out.println("b is true"); 
 
  } 
}



PreviousNext

Related