how to cast a string into an int java code example
Example 1: convert string to int java
String myString = "1234";
int foo = Integer.parseInt(myString);
Example 2: java convert String to int
int i = Integer.parseInt(myString);
Example 3: android studio parse to int
public class JavaStringToIntExample
{
public static void main (String[] args)
{
String s = "100";
try
{
int i = Integer.parseInt(s.trim());
System.out.println("int i = " + i);
}
catch (NumberFormatException nfe)
{
System.out.println("NumberFormatException: " + nfe.getMessage());
}
}
}