Continue statement

what is the use of continue in java ? I need a detailed explanation.

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html

Similar Messages

  • Getting error in continue statement

    Hi All,
    When i am writing the following code in java then i am getting syntex error in continue statement...
    Kindly tell me whyi am getting this one...
    package com.fidelity.ereview.utils;
    import java.io.*;
    * @author 197881
    public class Sunita {
          * @param args
         public static void main(String[] args) throws IOException {
              test: System.out
                        .print("Enter The Report Name to Generate(DataValidationReport/ErrorReport/ComparisionReport) : ");
              BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              String reportName = br.readLine();
              if (reportName.equalsIgnoreCase("DataValidationReport")
                        || reportName.equalsIgnoreCase("ErrorReport")) {
                   FileWriter f0 = new FileWriter("D:/TCS/" + reportName + "");
              } else {
                   System.out.println("Please Enter Correct Report Name");
                   continue test;
    }

    You need to be in some "loop" to use that:
    public static void main(String[] args) {
    test:
        while(true) {
            if (something) {
                continue test;
    }But I wouldn't advise it.

  • Continue Statement in export map

    Hey all,
      I need a definative answer on why the following is not working:
    ip prefix-list Management seq 5 192.168.0.0/16 le 32
    route-map Exp-Map permit 5
    description Management Nets to Management Provider 1
    match ip address prefix-list Management
    set extcommunity rt  1:1 additive
    continue
    route-map Exp-Map permit 10
    description Management Nets to Management Provider 2
    match ip address prefix-list Management
    set extcommunity rt  2:2 additive
    continue
    ip vrf Customer
    rd 3:3
    export-map Exp-Map
    route-target both 3:3
    PE1#show ip bgp vpnv4 all  192.168.1.1/32
    BGP routing table entry for 3:3:192.168.1.1/32, version 22
    Paths: (1 available, best #1, no table)
    Flag: 0xA20
      Advertised to update-groups:
         1        
      64774, (Received from a RR-client)
        10.98.98.98 (metric 30) from 10.98.98.98 (10.98.98.98)
          Origin IGP, metric 0, localpref 400, valid, internal, best
          Extended Community: RT:1:1 RT:3:3
          mpls labels in/out nolabel/33
    As you can see, it is though the continue statement is not working.
    I want to be able to use varying communities to allocate an RT.
    If the continue statement does not work, then I would need to allocate a community based on every permutation possible, which is allot.
    Cheers
    Adam

    Hi Adam,
    The "continue" keyword in a route-map forces the router to look at the next route-map sequence instead of stopping in the event of a match, as per normal route-map operation.
    In your example, you are making a match in sequence 10, the continue keyord will kick in and sequence 20 will be looked at, however, since you are matching on the same sequence of that prefix-list, the extra extcommunity will not be applied that you have requested in sequence 20.
    To get around this and acheive what you are trying to do, you can add both RT's to your route-map in sequence 10:
    Configured on PE1:
    ip prefix-list TEST_LOOPS seq 5 permit 25.25.25.25/32
    route-map EXP_MAP permit 10
    match ip address prefix-list TEST_LOOPS
    set extcommunity rt  25:25 35:35 additive
    ip vrf CUST_A
    rd 1010:1
    export map EXP_MAP
    route-target export 1010:79
    route-target import 2020:79
    Output from PE2:
    AS2020_PE#sh ip bgp vpnv4 all 25.25.25.25
    BGP routing table entry for 1010:1:25.25.25.25/32, version 30
    Paths: (1 available, best #1, no table)
      Not advertised to any peer
      1010
        6.6.6.6 (metric 20) from 6.6.6.6 (6.6.6.6)
          Origin incomplete, metric 0, localpref 100, valid, internal, best
          Community: 250:1
          Extended Community: RT:25:25 RT:35:35 RT:1010:79
            OSPF DOMAIN ID:0x0005:0x000000640200 OSPF RT:0.0.0.0:5:1
            OSPF ROUTER ID:1.1.1.1:1281,
          mpls labels in/out nolabel/19
    As you can see, the router assigns the two RTs to that 1 prefix you are matching on.
    If you are going to be adding more sequences to that same prefix-list, then yes you the "continue" keywork would work fine as the next route-map sequence would be matching on the next prefix-list sequence where it hits a match:
    Configured on PE1:
    ip prefix-list TEST_LOOPS seq 5 permit 25.25.25.25/32
    ip prefix-list TEST_LOOPS seq 10 permit 35.35.35.35/32     
    route-map EXP_MAP permit 10
    match ip address prefix-list TEST_LOOPS
    set extcommunity rt  25:25 additive
    continue
    route-map EXP_MAP permit 20
    match ip address prefix-list TEST_LOOPS
    set extcommunity rt  35:35 additive
      continue
    Output from PE2:
    AS2020_PE#sh ip bgp vpnv4 all 25.25.25.25
    BGP routing table entry for 1010:1:25.25.25.25/32, version 22
    Paths: (1 available, best #1, no table)
      Not advertised to any peer
      1010
        6.6.6.6 (metric 20) from 6.6.6.6 (6.6.6.6)
          Origin incomplete, metric 0, localpref 100, valid, internal, best
          Community: 250:1
          Extended Community: RT:25:25 RT:1010:79
            OSPF DOMAIN ID:0x0005:0x000000640200 OSPF RT:0.0.0.0:5:1
            OSPF ROUTER ID:1.1.1.1:1281,
          mpls labels in/out nolabel/19
    AS2020_PE#
    AS2020_PE#sh ip bgp vpnv4 all 35.35.35.35
    BGP routing table entry for 1010:1:35.35.35.35/32, version 24
    Paths: (1 available, best #1, no table)
      Not advertised to any peer
      1010
        6.6.6.6 (metric 20) from 6.6.6.6 (6.6.6.6)
          Origin incomplete, metric 0, localpref 100, valid, internal, best
          Community: 250:1
          Extended Community: RT:35:35 RT:1010:79
            OSPF DOMAIN ID:0x0005:0x000000640200 OSPF RT:0.0.0.0:5:1
            OSPF ROUTER ID:1.1.1.1:1281,
          mpls labels in/out nolabel/18
    AS2020_PE#
    HTH
    Joe.

  • My finder app is in a continuous state of crashing

    My finder app is in a continuous state of crashing and relaunching every 2 seconds or so, I can't open finder or time machine or my trash, as well as all of my desktop items are gone, I can still access the internet, but nothing online has helped me. If anybody has any solutions I would be extremely thankful. I'm using 10.6.8 . I have tried using terminal, or relaunching finder, nothing will work.

    You may be able to start up in SafeBoot and then read the Log files in the system profiler area, to see what kinds of oddities may appear or if there is some kind of kernel panic, etc going on. And while there in a booted state with limited OS X sections off by default, you may be able to see such basics as if the computer's hard disk drive is getting full, or if Disk Utility gives you any error messages when you Check Disk, and while there, note free vs used capacities, status of RAM (including VM as it uses drive space as RAM.)
    In the trouble and or crash logs, and basic running logs, Console is also a place to look, but there are very many; so this may be something to get into when or if someone who knows how to read the log file language sees your post and expresses a willingness to help decode them.
    If you have a backup, you may have to see about using 'secure erase' from the booted installer DVD or if your computer has no optical drive but has a recovery partition, see about using that system's Utilities to access Disk Utility, and then choose the Erase selection. And that would wipe the drive, and overwrite zeros on the old data; failed sectors may be tagged and avoided, or repaired, in so doing the drive would be clearer. Unless the hard disk drive is failing.
    There is a chance there may be something haywire, even corrupt/bad hard drive or bad RAM may act up, but Finder should not crash. There are related issues and ideas here, but in a later OS X version: https://discussions.apple.com/message/22273053#22273053
    Did you upgrade from an older system than 10.6(.8) or did that computer ship with the version installed? Some people upgrade over an older system and that effectively can carry a problem forward without resolving it. {edited}
    Good luck & happy computing!

  • Can anyone help me understand "Continue Statements"?

    Hi,
    I was wondering if anyone could help me understand continue statements. I've been studying the java tutorials this weekend but can not get my head around the following explanation: (My thoughts are at the end of this message and it might be easiest to read them first!)
    "The continue statement skips the current iteration of a for, while , or do-while loop. The unlabeled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop. The following program, ContinueDemo , steps through a String, counting the occurences of the letter "p". If the current character is not a p, the continue statement skips the rest of the loop and proceeds to the next character. If it is a "p", the program increments the letter count.
    {code}class ContinueDemo {
    public static void main(String[] args) {
    String searchMe = "peter piper picked a peck of pickled peppers";
    int max = searchMe.length();
    int numPs = 0;
    for (int i = 0; i < max; i++) {
    //interested only in p's
    if (searchMe.charAt(i) != 'p')
    continue;
    //process p's
    numPs++;
    System.out.println("Found " + numPs + " p's in the string.");
    }{code}
    Here is the output of this program:
    Found 9 p's in the string.
    To see this effect more clearly, try removing the continue statement and recompiling. When you run the program again, the count will be wrong, saying that it found 35 p's instead of 9.
    A labeled continue statement skips the current iteration of an outer loop marked with the given label. The following example program, ContinueWithLabelDemo, uses nested loops to search for a substring within another string. Two nested loops are required: one to iterate over the substring and one to iterate over the string being searched. The following program, ContinueWithLabelDemo, uses the labeled form of continue to skip an iteration in the outer loop.
    {code}class ContinueWithLabelDemo {
    public static void main(String[] args) {
    String searchMe = "Look for a substring in me";
    String substring = "sub";
    boolean foundIt = false;
    int max = searchMe.length() - substring.length();
    test:
    for (int i = 0; i <= max; i++) {
    int n = substring.length();
    int j = i;
    int k = 0;
    while (n-- != 0) {
    if (searchMe.charAt(j++)
    != substring.charAt(k++)) {
    continue test;
    foundIt = true;
    break test;
    System.out.println(foundIt ? "Found it" :
    "Didn't find it");
    }{code}
    Here is the output from this program.
    Found it"
    Here are Woodie's thoughts........................................
    1) With the first program I don't understand how the program counts the number of "p's". Like for example how it stores the number of "p's". Shouldn't it say:
    if (searchMe.charAt(i) = 'p') then store it in some sort of containers??? 2) With the second program, I don't understand the test section. For example: Why does it have --? why does it have != after while and why does it have != after if?
    while (n-- != 0)
                    if (searchMe.charAt(j++) != substring.charAt(k++))
                        continue test;
                foundIt = true;
                     break test;Edited by: woodie_woodpeck on Nov 23, 2008 3:29 AM

    Woodie, I think they're just silly "theoretical" examples... ergo don't worry too much not understanding them, coz they don't actually make a lot of sense... as you've allready pointed out there are other "more normal" control structures which achieve the same thing, and which in this case (in my humble opinion) would make for clearer, more concise, more maintainable code.
    All you need to know about continue is "it means go back to the top of the loop"... If you're not comfortable using "continue" then don't.
    There's more than one way to do it.
      public static void main(String[] args) {
        try {
          final String s = "peter piper picked a peck of pickled peppers";
          int count = 0;
          for ( char c : s.toStringArray() ) {
            if (c=='p') count++;
          System.out.println("There are "+count+ " p's in '"+s+"'");
        } catch (Exception e) {
          e.printStackTrace();
      }Having said all that... I did use continue in anger the other day... I was reading Geometries from a shape file... the reader was throwing an ArrayIndexOutOfBoundsException given an "empty Feature" (ie a feature with the geospatial presence)... All I did was catch the exception and continue trying to read the new feature... the alternative would have been to rewrite the control logic of the whole reader loop... quick, simple effective... but I don't routinely build continue statements into new code... just a matter of personal taste.
    Cheers. Keith.

  • Using the continue statement with an Iterator

    Hi everyone, got a problem; I am trying to use a continue statement to return to the start of a for loop. I am using an iterator in the for loop, not a conventional incremental/decremental counter. What is happening is that I am getting a NullPointerException because i.hasNext() is returning false. I know however, that there are subsequent records in the hashmap. Has anyone encountered this problem before? or has anyone tried to use continue with iterators? any help would be greatly appreciated!
    example of my code - This is important bit of loop:
    for (Iterator i = newCards.iterator(); i.hasNext();)
    accountID = (String) i.next();
    code where i do the continue:
    if (clientFlat.length() > 10)
    if (i.hasNext())
    System.out.println("i.hasnext has returned true and is about to continue");
    errorFlag = 2;
    continue;
    clientFlat is > 10, so it tests the i.hasNext condition. This is the problem, it returns false when it should be true.
    can anyone help? thanx

    Hi guys, can you help me...
    See my script... why the levelTemp value is different and yah, you right, the value inside iterator always some, but it is not equal with levelTemp before iteration..
    see this...
    public LinkedList getRecursiveChild() throws ClassNotFoundException, SQLException, Exception {
              LinkedList recursiveChildList,a;
              recursiveChildList = new LinkedList();
              String parent_id="";
              Iterator iterChild;
              int i=0;
              int levelTemp=0;
              DbTreeMembership dbTreeMembershipChild, dbTreeMembershipChildIterator;
              // query level 1, all downline of memberId;
              myDbBean.connect();
    mySQL = "SELECT * FROM membership WHERE parent_id='"+this.memberId+"'";
    myResultSet=myDbBean.execSQL(mySQL);
         while (myResultSet.next())
                   // query next level
                   // write all result to the list
                   parent_id = myResultSet.getString("membership_code");
                   // add to List
                   dbTreeMembershipChild = new DbTreeMembership( parent_id );
                   dbTreeMembershipChild.setLevel(level);
                   recursiveChildList.add( dbTreeMembershipChild );
                   // query level 2, if level 2 >= 1, add to list
                   // recursive procedure
                   DbTreeWalker dbTreeWalkerChild = new DbTreeWalker(dbTreeMembershipChild.getMemberId(), dbTreeMembershipChild.getLevel() + 1, this.recursiveList);
                   levelTemp=dbTreeMembershipChild.getLevel() +1;
                   System.out.println("leveltemp1:"+levelTemp);
                   a = dbTreeWalkerChild.getRecursiveChild();
                   iterChild = a.iterator();
                   // add child to LinkedList
                   while (iterChild.hasNext()) {
                        DbTreeMembership entry = (DbTreeMembership)iterChild .next();
                        dbTreeMembershipChildIterator = new DbTreeMembership( entry.getMemberId());
                        dbTreeMembershipChildIterator.setLevel(levelTemp);
                        System.out.println("leveltemp2:"+levelTemp);
                        recursiveChildList.add(dbTreeMembershipChildIterator);
              i++;
              recursiveChildCount=i;
              return      recursiveChildList;
         }

  • Alternative for Continue Statement in 10g

    Best way to write below code in Oracle 10g (as continue does not exist)
    BEGIN
    FOR i IN 1..10
    LOOP
    Dbms_Output.put_line(i);
    CONTINUE  WHEN i>5;
    CASE
    Dbms_Output.put_line(i);
    END LOOP;

    Nicosa wrote:
    I thought GOTO instructions were deprecated in all programming languages since the beginning of the 21st century...Agreed, of course - GOTO is usually a red flag indicating badly written code. However I think if it's used in a well-controlled way like this, and the label is something like<tt> continue_loop</tt>, then it might be allowed ;)

  • Is there any one knows how to use labview 6.0 to make a "continue" function like the one in C language?

    I am using labview 6.0 and i like to know is there any one knows how to stop the current iteration in while loop or for loop and continue to do the next iteration,just like the "continue" statement in C or C++ language?

    Simple test here in LV6 confims that you can't do this. Not in a useful
    sense anyway. "Stop" doesn't stop execution simply of the current VI, it
    also kills all VIs above it. It would hence be difficult to argue that this
    approach is in any way similar to "continue".
    What version of Labview have you tested this on and can you post a
    demonstration?
    Craig Graham
    Physicist/Labview Programmer
    Lancaster University, UK
    "Oleg" wrote in message
    news:506500000005000000E45B0000-1011517314000@exch​ange.ni.com...
    > Hi,
    > you can orginize all the inner actions of your while loop into the
    > SubVI. Then use the Functios/Application Control/Stop.vi in this SubVI
    > to stop the current interation in any point you want. This will stop
    > your SubVI and yo
    u will automatically goto the next iteration in your
    > while loop.

  • Newbie question about switch statement

    Lets say you have a loop and inside the loop you have a switch statement, how do you BREAK out of the outer loop?
    for (i=0....) {
    switch {
    case 11:
    .... some stuff
    break; <==== HOW DO I BREAK OUT OF THE for loop here?

    In standard C and standard C++ the break statement terminates the nearest enclosing loop and only that loop; i.e. control transfers to the first statement following the loop. I think there are C or C++ extensions that allow loop tags which may be used with a break to specify which loop to drop through, but I don't think these are supported by gcc, and they would certainly be very non-portable.
    There are several common ways to drop out of one or more outer loops. In many cases, there's nothing else in the loop following the switch so you can simply write
    switch (condition) {
    default:
    case 0:
    break;
    // other case statements here
    break;
    Else you can declare a loop control var and use the continue statement like this:
    for (i=0; i<jMax && !bDone; i++) {
    switch (condition) {
    default:
    case 0:
    bDone++; continue;
    // other case statements
    If you need to escape several loops and/or don't want to use loop control vars, you might consider structuring the code so you can use return to terminate the entire function. In the worst case of a very complex structure that you don't know how to simplify with a helper function, you can always resort to a goto:
    switch (condition) {
    default:
    case 0:
    goto escape;
    // other case statements here
    // remainder of code inside nested loops here
    escape: <first statement following the outermost loop>;
    Note that the statement following the escape label is always executed; i.e. when execution skips the goto it's as if the statement following escape was unlabeled. Use goto sparingly of course, since it's an artifact of unstructured programming. But when you really need a goto, it can make your code much easier to maintain.

  • How to use "continue"

    hi all
    i want to use "continue" statement in java... when i am doing this it says and trying to compile. But it says undefined label: error..
    any help on this
    thanks in advance

    i am using a method to send bulkmails to some emailAddresses.... if i got any wrong email then immediately it throws an exception after this exception my control is coming out of loop. So i am not able to send emails to the remaining addresses even they are correct email addresses.
    my code looks like this
         try
    System.out.println(""+recipients.length);
         InternetAddress[] addressTo = new InternetAddress[recipients.length];
              for (int i = 0; i < recipients.length; i++)
    //System.out.println(" <---------in forloop-------->"+recipients);
         start:
                   addressTo[i] = new InternetAddress(recipients[i]);
    //System.out.println("this is from bulk mail "+content);
    //System.out.println("this is from bulk mail "+subject);
                   boolean debug = false;
                   String smtpHost="mail.ipointsoft.com";
                   String htmlString = "<html><head><title>" +
                   "</title></head><body><font class=verdana size=2><b>To Unsubscribe please<i><a href='http://192.9.1.7:8080/Unsubscribe?unsub="+addressTo[i]+"'> click Here...</a></i></b></font>"+
                   "<p>" +
                   " </body></html>";
    //System.out.println("------->from blk mail"+smtpHost+"----------");
                   //Set the host smtp address
                   Properties props = System.getProperties();
                   props.put("mail.smtp.host", smtpHost);
    //System.out.println("<----------attachment------------->"+attachment+"<------------");
                   //create some properties and get the default Session
                   Session session = Session.getDefaultInstance(props, null);
         session.setDebug(debug);
    //System.out.println("<----------i am after getting session------------->");
              // create a message
                   Message message = new MimeMessage(session);
    //System.out.println("<----------i am after getting msg------------->");
              // set the from and to address
                   InternetAddress addressFrom = new InternetAddress(from);
                   message.setFrom(addressFrom);
                   message.addRecipient(Message.RecipientType.TO, addressTo[i]);
    //System.out.println("<----------i am after setting the to address------------->");
                   // Optional : You can also set your custom headers in the Email if you Want
                   message.addHeader("MyHeaderName", "myHeaderValue");
                   // Setting the Subject and Content Type
                   message.setSubject(subject);
                   BodyPart part1=new MimeBodyPart();
                   part1.setText(content);
                   BodyPart part2=new MimeBodyPart();
                   DataSource source =new FileDataSource(attachment);
                   part2.setDataHandler(new DataHandler(source));
                   part2.setFileName(attachment);
                   MimeBodyPart part3 = new MimeBodyPart();
                   part3.setDataHandler(new DataHandler(new HTMLDataSource(htmlString)));
                   MimeMultipart multipart=new MimeMultipart();
                   multipart.addBodyPart(part1);
                   multipart.addBodyPart(part2);
                   multipart.addBodyPart(part3);
                   message.setContent(multipart);
    System.out.println("this is before calling send method on Transport Class $$$$$$$$$$$$$$$$$$");
                   Transport.send(message);
                   System.out.println("mail send sucessfully");
                   }//end of for()--loop
              }//end of try-catch() block
              catch(Exception e)
    System.out.println("mail did't send sucessfully********");
                   e.printStackTrace();
                   return false;
                   continue start;
    System.out.println("i am returning return");
    return true;
    thanks in advance

  • BPEL implement while-continue logic

    Greetings,
    In java, one could use the continue statement to skip current iteration within a while, for or do-while loop.
    Is it possible to implement similar flow control in BPEL within in a while activity?
    Thanks.

    Sure, in my case, I have a variable list of elements that I am dealing within the while loop activity.
    E.G. I have an array of addresses. In the while loop, for each address, I want to execute some logic only if the address is valid. I check if the address is valid first thing inside the loop. If the address is invalid, then I want to skip current iteration and proceed with rest of the elements.
    Alternatively, I could iterate over the array first, pick only valid address assign it to a temp array and then reiterate again on all valid addresses in the temp array. This will involve iterating over the array elements twice, which I was tying to avoid.
    It would be nice to have a "continue" statement in BPEL!
    Thanks.

  • SAPScript - add 'continued' in next page.

    Hi Guys,
    I would like to ask on how to write 'continued' at the new page?
    My SAPScript form is depend on the data that will output. When the data is exceeded from the MAIN window, it will automatically break the data to pages. So may i know how i want to write 'continued' when it breaks the data to the new page?

    Thanks for the answer.
    But how if i want to write 'continued' in the main window?
    For example:
    in my main window the output will be like this:
    data 1
    data 2
    data 3
    ......(and so on)
    if the 'data 2' has reach the end of the page, 'data 3' will be print in next page. I want to know how to write 'continued' before the 'data 3' be printed?
    i tried to put this coding in the text element,
    /E 101
    /:  if new page
    /:  continued
    /:  endif
    &symbol&
    but the out put will be like this:
    continued
    data 3
    continued
    data 4
    continued
    data 5
    ...(and so on)
    The 'continued' statement will be repeating on each line of data.
    Edited by: BobKur on Jun 19, 2009 9:43 AM

  • Discrete state-space representation in FPGA

    Hello all,
    My aim is to simulate a discrete state-space model is the cRIO FPGA (in order to use an observer).
    I am currently trying to simulate it on my computer without using the discrete state-space VI from the Control Design and Simulation toolbox (because there is not state-space model VI for the FPGA). However my discrete state-space model representation does not work.
    There is below the continuous state-space model:
    Then I obtained the discretized model (using the zero-order-hold and t=0.01s):
    Below is the discretized state-space model I designed (in order to design a similar model in the FPGA):
    Here is the discrete state-space VI I'm using to compare the results:
    The graph plots the state X1, which is infinitely increasing. However it should look like a first order, as you can see:
    I understand why the state X1 is increasing like this, I know I'm missing something (integration saturation ?).
    Thanks in advance
    Regards!
    PS: Does somebody know if implenting other controller than the PID is doable in the cRIO FPGA? I also asking myself about matrix inversion if I want to use the Kalman gain in my observer.
    PS2: I apologize for my disorganized/unclear Labview files, I'm beginning with it.
    Solved!
    Go to Solution.
    Attachments:
    SS Discret Simulation.vi ‏544 KB
    SS Discret Model.vi ‏21 KB

    Hi,
    I think the problem might be caused by rounding errors in your A and B matrices.  Have you tried getting it to display the values with greater precision?
    Matlab calculates those values as:  A = [0.995, 0.009925; 0 0.99],  B = [2.488e-5; 0.004975]
    Regards,
    Ian

  • IMAQ-continuous image acquisition for VB

    C:\Program Files\National Instruments\NI-IMAQ\Sample\MSVB.NET\Getting Started
    Configure()
    CWIMAQ1.Start()
    CWIMAQViewer1.Attach(CWIMAQ1.Images.Item(1)) <--------I do not understand  
    Can teach me
    And, how to acquire the single image under the continuous state.

    Burki,
    Are you trying to save the continuous images as a movie?  This is not supported in VBAI, however if you wish to snap continuous frames individually you can try editing your inspection state diagram to repeat your current inspection and transition to the stop step only after your current inspection has been performed a set number of times.
    Regards,
    Isaac S.
    Applications Engineer
    National Instruments

  • While, try/catch and continue

    Hello,
    i've got a while-loop which executes some statements. some of them are within a try-catch block.
    imagine like this:
    while (channelsIT.hasNext()) {
       RSSChannel channel = channelsIT.next();
       RSSChannelReader reader = new RSSChannelReader(channel.getStrRSSUrl());
       try {
          reader.connect();
       } catch (Exception e) {
          log.error("Fehler beim Lesen eines RSS-Channels", e);
          continue;
       Collection items = reader.getChannelItems();
    }As you may see, it makes no sense in this case to continue the loop after reader.connect() failed. for that, I tried to use the continue statement, but the code interrupts after the logging and the application failes.
    the workaround is to put all the code of the while loop into the try-block, but for that seems to be a bad solution.
    while (channelsIT.hasNext()) {
       RSSChannel channel = channelsIT.next();
       RSSChannelReader reader = new RSSChannelReader(channel.getStrRSSUrl());
       try {
          reader.connect();               
          Collection items = reader.getChannelItems();
       } catch (Exception e) {
          log.error("Fehler beim Lesen eines RSS-Channels", e);
          continue;
    }so why does my first code not work properly?
    Thank you for any suggestions.

    Then I misunderstood you.
    public class Test {
      public static void main(String args[]) {
        int i = -1;
        while (i < 10) {
          int j = i % 2;
          i++;
          try {
            System.out.print(i / j);
          } catch (Exception e) {
            System.out.println(i + " skipped");
            continue;
          System.out.println(" - after");
    }This writes "after" if there's no exception and skipped if there is one:
    0 - after
    1 skipped
    2 - after
    3 skipped
    4 - after
    5 skipped
    6 - after
    7 skipped
    8 - after
    9 skipped
    10 - after
    So it behaves exactly as you want it to, and so should your first code. Is it the exact code you posted, including "catch (Exception"?

Maybe you are looking for