java - Can I convert a String variable into a int variable -


this question has answer here:

is there way integer variable string object, like:

string string = "render.screen_width_tiles"; // screen_width_tiles render integer value referenced in other class 

i want string variable hold reference specified int.

what want string value "transform it" int value,

is possible this?

i can't find way handle integer value variable in string.

you seem misunderstanding how integer.parseint(s) works. documentation states:

parses string argument as signed decimal integer. characters in the string must decimal digits, except first character may ascii minus sign - (\u002d) indicate negative value or ascii plus sign + (\u002b) indicate positive value.

the parameter integer.parseint(s) must string contains number. such as:

  • integer.parseint("12345")
  • integer.parseint("-45")

but not:

  • integer.parseint("hello world")
  • integer.parseint("this not work 4 you")

and not: integer.parseint("render.screen_width_tiles - 1");


Comments