Java Program to convert String to Integer using Integer.parseInt()


The Integer.parseInt() method in Java converts a string to an integer.

Let’s say the following is our string −

String str = "456";

Converting it into integer −

Integer.parseInt(str));

The following is the complete example −

Example

 Live Demo

public class Demo {
    public static void main(String[] args) {
       String str = "456";
       System.out.println(Integer.parseInt(str));
    }
}

Output

456

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

162 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements