Is there any way to update the loop variable in for loop from another class in java?
For example let's consider a class mytest.java as 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 as follows:
public class checker()
{
public boolean check(int i)
{
if(i==5)
{
//Here if value of i is 5, i don't want to do any
//more operation but just update the for loop of
// of mytest class and continue with later iterations.
}
else
{
//there may be many more operations like calling other
// methods or other class.
}
}
}