Java Integer(String s) Constructor
Syntax
Integer(String s) constructor from Integer has the following syntax.
public Integer(String s) throws NumberFormatException
Example
In the following code shows how to use Integer.Integer(String s) constructor.
public class Main {
public static void main(String[] args) {
/* w w w. j a v a 2 s . c om*/
Integer integer1 = new Integer("1");
Integer integer2 = new Integer("2");
System.out.println(integer1);
System.out.println(integer2);
}
}
The output: