❔ i need some help getting out of loop
im in a infinite loop and not sure how to get out. tldr im very new as im still trying to learn
10 Replies
always start with properly defining your problem
what is the loop behavior you WANT to achieve?
im stuck in a loop and i cant get out of it, and i need a way to check to see if a user input exists in the array i have
i dont know how more define my problem then that honestly
Can you check your condition in the
while
statement?then that's where younneed to start
what do you want this loop to do?
what is it supposed to do?
so i aks the user what gas they want they enter it, then the different exceptions to make sure they write the name correctly if not they are force back to try again. once they enter correct they move on
Look at your while condition
thank you
Wait how can you get formatexception or even overflowexception if you only read input from console as a string?
Hell any exception
yeah the exception handling doesn't make any sense, they will never be thrown let alone thrown for what you seem to expect in that code
don't use exceptions for flow control regardless
they're for things you don't expect to happen, but you clearly expect that the user might input an invalid/wrong gas name
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.