Java Program to convert from String to integer



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
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements