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