Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:39:03+00:00 2026-06-11T07:39:03+00:00

while (true) { try { //create ImportantObject LoopToGoTo: for (int i = 0; i

  • 0
while (true) {
    try {
        //create ImportantObject
        LoopToGoTo:
        for (int i = 0; i < Limit; i++) {
            //method in here throws the exception
            //ImportantObject is used in here.
        }
    } catch(Exception e) {
        //report error
        continue LoopToGoTo;
    }
}

I would like to continue at a loop that is inside the try catch block. Is this possible?

EDIT: Sorry, I was not clear on why I couldn’t move the try catch to inside the for loop. (edited snippet) If I put the try-catch inside the for loop, the calls inside won’t be able to access the ImportantObject.. This is where I was stuck.

EDIT2: Okay, I resolved my problem, albeit without continue with label! I guess the answer to my question is a simple ‘no’. Bad habits might be all over the place, but my assignments due in two hours. what can i say 😀

//ImportantClass ImportantObject = null;
while (!ranOnce) {
    try {
        //create ImportantObject
        ranOnce = true;
    } catch(Exception e) {
        //report error
        continue;
    }
}
for (int i = 0; i < Limit; i++) {
    try {
        //method in here throws the exception
        //ImportantObject is used in here.
    } catch(Exception e) {
        //report error
        continue;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:39:05+00:00Added an answer on June 11, 2026 at 7:39 am

    No, it is not possible, since you are already outside of the scope of the try block.

    Why not just move the try catch inside the for loop?

    for (int i = 0; i < Limit; i++) {
        try {
            //method in here throws the exception
        } 
        catch(Exception e) {
        //report error
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to generate a KeyboardInterrupt in Windows? while True: try: print 'running' except KeyboardInterrupt:
try { if (myBoolean) { while (true) ; } else { System.exit(1); } }
As of now I'm using a while(true) method to detect changes in memory. The
here is my script: from random import * from turtle import * while True:
<?php while(true){ //code goes here..... } ?> I want to make a PHP web
while (true) { //read in the file StreamReader convert = new StreamReader(../../convert.txt); //define variables
from random import * while True: random1 = randint(1,20) random2 = randint(1,20) print(h =
Consider the following code: while(true) { someFunction(); Thread.sleep(1000); } What I want is that,
Let's say I accidentally wrote this: do { } while (true); ...and then ran
Consider this code: import socket store = [] scount = 0 while True: scount+=1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.