Right, I'm pretty new to programming in general, and java is annoying me atm. Can't really get used to it.
I'm asking the to input something as a string, then I need to check if the value can be converted to a double or not (the user should be able to enter a number, and the program does one thing, or enter a string, and it does another).
Not quite sure how to do it. I know in something like python I could just do a try and except statement (try converting it to a double, and if it can't, use the except statement to say what to do then), not sure how to do it in java.
Question
WelshBluebird
Right, I'm pretty new to programming in general, and java is annoying me atm. Can't really get used to it.
I'm asking the to input something as a string, then I need to check if the value can be converted to a double or not (the user should be able to enter a number, and the program does one thing, or enter a string, and it does another).
Not quite sure how to do it. I know in something like python I could just do a try and except statement (try converting it to a double, and if it can't, use the except statement to say what to do then), not sure how to do it in java.
Sorry if its a noobish question lol. Thanks.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts