+ 2

Can i change string into integer in java

29th Jul 2018, 5:26 AM
Var name = "";
Var name = ""; - avatar
4 Respostas
+ 9
String number = "10"; int result = Integer.parseInt(number); System.out.println(result); String number = "10"; Integer result = Integer.valueOf(number); System.out.println(result); String number = "10A"; int result = Integer.parseInt(number); System.out.println(result);
29th Jul 2018, 5:29 AM
Scooby
Scooby - avatar
+ 8
Yes you can. Bet you want to know how to do it too. https://www.geeksforgeeks.org/string-to-integer-in-java-parseint/
29th Jul 2018, 5:30 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
You can use Integer.parseInt() method to convert from string to integer. I think it would be easy to implement and to understand better for beginners
29th Jul 2018, 1:34 PM
Rohini P S
Rohini P S - avatar
+ 1
the best option is valueOf(string). You should read about casting. :)
29th Jul 2018, 11:41 AM
Teresa Guerrero
Teresa Guerrero - avatar