Examples of good gotos in C or C++ [closed]

Heres one trick I’ve heard of people using. I’ve never seen it in the wild though. And it only applies to C because C++ has RAII to do this more idiomatically. void foo() { if (!doA()) goto exit; if (!doB()) goto cleanupA; if (!doC()) goto cleanupB; /* everything has succeeded */ return; cleanupB: undoB(); cleanupA: … Read more

Is there a goto statement in Java?

James Gosling created the original JVM with support of goto statements, but then he removed this feature as needless. The main reason goto is unnecessary is that usually it can be replaced with more readable statements (like break/continue) or by extracting a piece of code into a method. Source: James Gosling, Q&A session