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
Published on 07-Feb-2018 06:12:49
Advertisements