Thursday, 6 July 2017

java - Can I read a string and then use it as an integer?











MY code is supposed to read strings and then take the corresponding actions, but if that string is a line of numbers i need this line as a full number (an int) not as a string anymore.can this be done?


Answer



Use Integer.valueOf:



int i = Integer.valueOf(someString);



(There are other options as well.)


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...