0
Safe casting form sting to int
2 Respostas
+ 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
}
- 1
can use as to cast