Java Program to convert from String to integer

Java 8Object Oriented ProgrammingProgramming

Use the Integer.parseInt() method in Java to convert from String to integer.

Let us first take a string.

String str = "200";

Now let us convert it to integer.

int val = Integer.parseInt(str);

Let us now see the complete example.

Example

 Live Demo

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

Output

Integer: 200
raja
Published on 12-Nov-2018 10:33:49
Advertisements