Is there a java compiler flag that allows me to use goto
as a valid construct? If not, are there any third-party java compilers that supports goto
?
Pretty much anything you can do with goto you can do with a loop. goto is really redundant and generally discredited way to program. IMHO.
If you want to goto backwards
LABEL: do {
// code before goto
// goto LABEL
continue LABEL;
// code after goto
break;
} while(true);
If you want to goto forwards
LABEL: do {
// code before goto
// goto LABEL
continue LABEL;
// code after goto
break;
} while(false);
// Label is effectively here
// code after LABEL.