continuing next iteration of **for** loop in java if any method fails in another class? -


is there way update loop variable in for loop class in java?

for example let's consider class mytest.java follows:

 public class mytest()         {                 public static void main(string[] args)                 {                    for(int i=0;i<10;i++)                    {                        new checker().check(i);                    }                 }         } 

now consider class checker.java follows:

public class checker() {     public boolean check(int i)     {          if(i==5)          {              //here if value of 5, don't want               //more operation update loop of              // of mytest class , continue later iterations.          }          else          {               //there may many more operations calling other               // methods or other class.          }    } } 

you can return value check() method integer , assign loop variable i.

as per example:

public class checker {     public int check(int i)     {          if(i==5)          {              //here if value of 5, don't want               //more operation update loop of              // of mytest class , continue later iterations.          }          else          {               //there may many more operations calling other               // methods or other class.          }        return i;     } } 

and in mytest class can assign value loop variable.

public class mytest {       public static void main(string[] args)       {             for(int i=0;i<10;i++)             {                 int temp = new checker().check(i);                 if (condition)                   i= temp;              }         }  } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -