English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program to Convert String to int

UsingparseInt()The method in Java converts String to int.

First, include a string.

String str = "999";

Now, let's convert it to int.

int val = Integer.parseInt(str);

Let's see the complete example.

Example

import java.util.Random;
public class Demo {
   public static void main(String args[]) {
      String str = "999";
      int val = Integer.parseInt(str);
      System.out.println("Integer = ",+val);
   }
}

Output Result

Integer = 999