MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/jtg3hx/getting_digits_using_switch_catch/gc6v2ws/?context=3
r/badcode • u/HolySpecs • Nov 13 '20
52 comments sorted by
View all comments
9
Just use Interger.parseInt(str);
3 u/HolySpecs Nov 13 '20 edited Nov 13 '20 I wanted to do that but the normal inputs for the program were like:+99 9 -98 &4 &4+89 (this line is wrong)so if I did use Integer.parseInt(str) then I would get errors if, for example:9+9was entered 1 u/CollieOop Nov 13 '20 So instead you made a function that will call System.exit(2) on those inputs being entered instead of throwing an exception?
3
I wanted to do that but the normal inputs for the program were like:
+99 9 -98 &4 &4+89 (this line is wrong)
so if I did use Integer.parseInt(str) then I would get errors if, for example:
9+9
was entered
1 u/CollieOop Nov 13 '20 So instead you made a function that will call System.exit(2) on those inputs being entered instead of throwing an exception?
1
So instead you made a function that will call System.exit(2) on those inputs being entered instead of throwing an exception?
9
u/jubiman Nov 13 '20
Just use Interger.parseInt(str);