xxxxxxxxxx
String myString = "1234";
int number = Integer.parseInt(myString);
xxxxxxxxxx
int result = Integer.parseInt("500");
System.out.println(result) // prints 500 as int
xxxxxxxxxx
String number = "10";
int result = Integer.parseInt(number);
System.out.println(result);
Copy
xxxxxxxxxx
s := "97"
if n, err := strconv.Atoi(s); err == nil {
fmt.Println(n+1)
} else {
fmt.Println(s, "is not an integer.")
}
// Output: 98
xxxxxxxxxx
String number = "10";
int result = Integer.parseInt(number);
System.out.println(result);
xxxxxxxxxx
class Scratch{
public static void main(String[] args){
String str = "50";
System.out.println( Integer.parseInt( str )); // Integer.parseInt()
}
}