Can i use goto statement to jump from one method into another in c++ , java or c#.
Asked
Active
Viewed 3,356 times
0
-
@ShashankKadne: That is incorrect, C++ does not support `goto` jumping between methods. – Greg Hewgill Feb 25 '12 at 07:10
-
@GregHewgill: I can't even label a method and then call goto to jump to that label??....i never tried it! – Shashank Kadne Feb 25 '12 at 07:14
-
1@ShashankKadne - no you can't. Try it. The compiler won't let you. And in the Java case, `goto` is not supported because the designers thought it was a bad language feature, not because of any real or imaginary security concerns. – Stephen C Feb 25 '12 at 07:19
-
Thanks folks...that means my comment makes no sense. I should better remove it. – Shashank Kadne Feb 25 '12 at 07:23
3 Answers
2
Not with java. goto
is a reserved word (statement) but it is not useable by design.
Further reading:

Community
- 1
- 1

Andreas Dolk
- 113,398
- 19
- 180
- 268
-
Interesting. Had no idea about `goto` in java being just wrong syntax. – Jason Webb Feb 25 '12 at 07:46