Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+36 votes
asked in CSC285_Fall2018 by (8 points)

1 Answer

+14 votes

You can use the static method parseInt(String) in Integer class that will throw an number format exception if you did not pass a numeric String. We can catch the exception and print out the message or return the boolean value.

You can also use the classes listed in this link: https://stackoverflow.com/questions/1102891/how-to-check-if-a-string-is-numeric-in-java
... to use the method, but I don't think it is available in our Eclipse right now.

answered by (8 points)