This site requires JavaScript, please enable it in your browser!
Greenfoot back
paul10y
paul10y wrote ...

2013/1/21

converting strings to numbers

paul10y paul10y

2013/1/21

#
Hello, i have a general java question: There is the possibility to convert a number (like int a = 126) to a string with: String x=""+a. That would be x="126". But is there a way to turn it back, so that i have a string variable and "convert" it to an (for example) int type (as long as the string is a number, I dont even want to try to convert sth like "qwert123", but maybe String x="621" to int a=621)
danpost danpost

2013/1/21

#
int a = Integer.valueOf(x);
paul10y paul10y

2013/1/21

#
It worked, thank you really much! :D
You need to login to post a reply.