chaîne à int java
String number = "10";
int result = Integer.parseInt(number);
System.out.println(result);
Copy
Tame Thrush
String number = "10";
int result = Integer.parseInt(number);
System.out.println(result);
Copy
// You will receive an error if there are non-numeric characters in the String.
String num = "5";
int i = Integer.parseInt(num);
var text = '42px';
var integer = parseInt(text, 10);
// returns 42
class scalerAcademy {
public static void main ( String args [] ) {
String str = "789"; // creating a string
Integer ans = Integer.valueOf(str); // passing the value to an Integer class
Integer ans1 = Integer.valueOf(str,16); // passing radix value as int
System.out.println(ans); //outputs 789
System.out.println(ans1); // outputs 1929
}
}