How to convert a String to an int in Java


Following example is converting a String to int.

Example

Live Demo

public class Tester {
   public static void main(String[] args) {
      String intString = "1234";
      int value = new Integer(intString).intValue();
      System.out.println(value);
   }
}

Output

1234

Updated on: 25-Feb-2020

269 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements