Results 1 to 2 of 2

Thread: statement in java program

  1. #1
    PetersonClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    202
    Rep Power
    3

    Default statement in java program

    How to use the continue statement in java program?

    Recently I started learning java language. I want to write java program using continue statement. I tried different ways but I not able to write right program. Can anybody tell me How to use the continue statement in java program? Any suggestion.

  2. #2
    CollinsBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    213
    Rep Power
    3

    Default

    It is used to transfer normal flow control to other condition. It is used to break normal flow control. You can use Continue statement anyplace in the program. Just ensure that it should be at the end of any loop and then there should have one more loop condition. Just try the following program which is helpful for you.

    public class Continue{
    public static void main(String[] args){
    Thread t = new Thread();
    int a = 0;
    try{
    for (int i=1;i<10;i++)
    {
    if (i == 5)
    {
    continue;
    //control will never reach here (after the continue statement).
    //a = i;
    }
    t.sleep(1000);
    System.out.println("chandan");
    System.out.println("Value of a : " + a);
    }
    }
    catch(InterruptedException e){}
    }
    }

Similar Threads

  1. Scheduled task program in java
    By CoxWatson in forum Programming
    Replies: 1
    Last Post: 04-17-2010, 12:53 PM
  2. Java program to use enemy in change statement.
    By WalkerCook in forum Programming
    Replies: 1
    Last Post: 02-17-2010, 05:49 PM
  3. Java program
    By MoralesWard in forum Programming
    Replies: 1
    Last Post: 02-02-2010, 05:16 PM
  4. the ternary operator in java program
    By WilsonMartin in forum Programming
    Replies: 1
    Last Post: 01-28-2010, 06:07 PM
  5. Write program on palindrome in java
    By MoralesMyers in forum Programming
    Replies: 2
    Last Post: 01-14-2010, 06:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48