I feel like there should be a better way to do this. Maybe without creating the string and going straight to parsing instead? But when I do that, I have difficulty incorporating that solution so that the boolean will be modified if the input is read. There is no problem when it's passed into the string however. That's working as intended.
Any tips on what I'm looking for to learn?
For example:
Instead of using s =(input)
x += parse s
boolean s.equals(-1)
print x
Is it possible to just straight up parse the input, append it within the same variable x and then display the results? I run into problems with the boolean when I try to have it check the input that is parsed. I also have trouble getting it to check it before it is parsed if I don't assign the input as a string first (Obviously).
Can it be more efficient? (I'm not allowed to post solution)
Resolved
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
AnnemiekFF
27 May 2020, 14:20useful
You can just parse it yes. With Integer. parseInt(<read data into here>) you will get an int if you enter a value, or a numberFormatException if it is not possible.
+2