集册 Java实例教程 创建整数对象

创建整数对象

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

577
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建整数对象

 

public class Main {

 

  public static void main(String[] args) {
  /*
   from NowJava.com 
  */

    //1. Create an Integer object from int

    Integer intObj1 = new Integer(10);

   

    /*

    2. Create and Integer object from String. 

    */

    Integer intObj2 = new Integer("10");

   

    //print value of Integer objects

    System.out.println(intObj1);

    System.out.println(intObj2);

  }

}