How to convert a String to an int in Java

Java 8Object Oriented ProgrammingProgramming

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
raja
Updated on 25-Feb-2020 05:20:34

Advertisements