+ 2
Can't we use continue outside loops????
I tried using it outside any loop but it only shows label missing. Is it possible that I can only use continue inside loop?
3 Respuestas
+ 16
we use continue , to skip the statement(s) for some particular cycles , there is no need of continue outside a loop[its better to use if else]
0
I wanted to build a program where in the end the user will be asked once if he or she want to leave or go back.. and to go back I used continue. What should I use for it then??
0
No, continue can not be used outside loops.
A solution for your problem might be: Get a method like questionExit () which returns a boolean value depending on how the user decided. If he wants to leave (if statement here!), you stop your programm or something else. If he doesn't, you either do nothing or go back or something what you want...