I want to convert a string to integer. I wrote following code but it throws exception.
Exception:Code:String str = "22";
int a = (int)str;
Can anyone indicate the problem area?Code:Cannot cast from String to int
-PEACE
Printable View
I want to convert a string to integer. I wrote following code but it throws exception.
Exception:Code:String str = "22";
int a = (int)str;
Can anyone indicate the problem area?Code:Cannot cast from String to int
-PEACE
You can use the following lines of code
String a = "123"
int number = Integer.parseInt(a);
Perfect. It is now ok. Thanks for your help.
- PEACE