English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Create an integer object using Java

Creating an Integer object in Java is very easy. To do this, let's understand the following two methods.

Method1

Example

public class Demo {
   public static void main(String []args) {
      Integer obj = new Integer("199);
      System.out.println(obj);
   }
}

Output Result

199

Method2-Now let's see the second method

Example

Public class Demo {
   public static void main(String []args) {
      Integer obj = new Integer(99);
      System.out.println(obj);
   }
}

Output Result

99