Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Goto needed in a Java for loop with lots of 'switch-case' statements

807580Apr 27 2010 — edited Apr 29 2010
Unbelievable. I really need the 'goto' statement.

I'm completing a file parser-inserter method that inserts data from a second file during the parsing of a first file.
A huge 'for()' statement with 9 levels of embedded 'switch-case' and 'if' condition statements. About 4000 lines. Months of work. But this method is not dividable, is clearly documented and works fine.

In seldom cases, I should have great benefice if I could disturb the main 'for()' loop and the 'switch-case' routing, retaining the state before the de-routing and restoring it at the right time. Therefore, I absolutely need the 'goto label' capability. A label at the head of each embedded 'switch-case'. It is all very clean, I can assure you.

My NetBeans IDE recognizes the 'goto' word (turning it in blue). What is the exact syntax of the calling statement (goto mylabel;) and the called line (mylabel:) ? Or is 'goto' really not provided by Java ?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2010
Added on Apr 27 2010
39 comments
636 views