Syntax error How to convert a String to an int in Java

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: 2020-02-25T05:20:34+05:30

445 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements