I am trying to do something like this:
String text = TextBox1.getText();
int number = (int)text;
It is not letting me cast a string to an integer.
Can anyone tell me how to do this?
Printable View
I am trying to do something like this:
String text = TextBox1.getText();
int number = (int)text;
It is not letting me cast a string to an integer.
Can anyone tell me how to do this?
Of course you can't cast a string to an integer. :lol: Use
int i = Integer.parseInt(s); where s is a String reference.
Then you can go back from an int to a String.
int i = Integer.parseInt(s);
String s2 = String.valueOf(i);
I really hate making dumb mistakes!!
Thank you