0

Safe casting form sting to int

18th Feb 2017, 6:10 AM
Mostafa Selim
Mostafa Selim - avatar
2 odpowiedzi
+ 3
If you really want to convert a string into integer, you should PARSE it. Try Integer.parseInt() with proper exception handling. You can also use Integer.valueOf(), which uses Integer.parseInt() internally. For example, try { int result = Integer.parseInt("3599"); // you will get an integer value 3599 } catch (NumberFormatException e) { // exception handling code fragment }
18th Feb 2017, 7:19 AM
Jian-hua Yeh
Jian-hua Yeh - avatar
- 1
can use as to cast
18th Feb 2017, 7:29 AM
Mostafa Selim
Mostafa Selim - avatar