集册 Java实例教程 将布尔型基本体转换为布尔型对象

将布尔型基本体转换为布尔型对象

欢马劈雪     最近更新时间:2020-01-02 10:19:05

413
将布尔型基本体转换为布尔型对象

public class Main {

 

  public static void main(String[] args) {//来 自 n o w j a v a . c o m - 时代Java

    boolean b = true;

   

    //1. using constructor

    Boolean blnObj1 = new Boolean(b);

   

    //2. using valueOf method of Boolean class. This is a static method.

    Boolean blnObj2 = Boolean.valueOf(b);

  }

}