Convert string to int with Java

In Java to convert a string to int requires the class java.lang.Integer.

Primitive int

The returned result will be a primitive integer.

String number = "1234567890";
int result = Integer.parseInt(number);
System.out.println(result);

Integer object

The returned result will be an integer object.

String number = "1234567890";
Integer result = Integer.valueOf(number);
System.out.println(result);