-2

i am trying to loop something so that it will restart after a few minutes.

here is my code

private static boolean online = false;

public static boolean isStreamLive() {
  {  firstloop: if(online == false) {
     try {
         URL url = new URL(  insertChannel(TWITCH_STREAM, "nyankosaan") );
         URLConnection conn = url.openConnection();
         BufferedReader br = new BufferedReader( new InputStreamReader( conn.getInputStream() ));
         String inputLine = br.readLine();
         br.close();
         JsonObject jsonObj = JsonObject.readFrom(inputLine);
         return ( jsonObj.get("stream").isNull() )?false:true;
        } 
        catch (IOException e) 
        {
            e.printStackTrace();
        } 

    } else {
     if(isStreamLive() == true);
     try {
         continue;

    } finally {

    }



    }

return online;
}

 }
 }

for some reason the continue has an error saying "continue cannot be used outside of a loop". can anyone help me figure out why its saying that?

nyanchan
  • 3
  • 3
  • Do you have a loop in your code? If not, what do you expect `continue` to do? – PM 77-1 Mar 14 '15 at 05:41
  • Read [this](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html) carefully. – MarsAtomic Mar 14 '15 at 05:46
  • `if(isStreamLive() == true);` should not have a semicolon... – Elliott Frisch Mar 14 '15 at 05:46
  • I recommend that you review Java keywords, such as [looping](http://www.tutorialspoint.com/java/java_loop_control.htm), as well as [try-catch](http://www.tutorialspoint.com/java/java_exceptions.htm), because you have no loop, and your using a try statement without a catch, and no exception is thrown by `continue`. – jpdymond Mar 14 '15 at 05:50

1 Answers1

2

There are three types of loops in java

1) for loops:

for (initialization; condition; increment) {
   //...
}

2) While loops

while (conditon) {
    //...
}

3) Do- While loops

do {
    //...
} while (condition);
jpdymond
  • 1,517
  • 1
  • 8
  • 10