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
class Scratch{
public static void main(String[] args){
String str = "50";
System.out.println( Integer.parseInt( str )); // Integer.parseInt()
}
}
xxxxxxxxxx
class scratch{
public static void main(String[] args) {
String str = "54";
int num = Integer.parseInt("54");
double doub = Double.parseDouble("54");
}
}
xxxxxxxxxx
int sample2 = Integer.parseInt("47"); // returns 47
int sample3 = Integer.parseInt("+4"); // returns 4