So today, while studying Java, I finally came across this particular error. This error seems to be fairly common, and trying to recover it caused mixed reactions. Some people think that it is useful in certain scenarios , so its good to know, some used it in their projects , while others vehemently oppose the idea of catching this error, and then many others are just as confused as I am .
Edit: Oh by the way, this is the error I encountered. I want to catch these errors and reduce the incrementor value by 1/10 the next time until another error is found
(and so on ... until I find the upper bound)

Since I am taking my children’s steps in Java and cannot find anything special about this topic, I would like to ask your help in this specific example:
public class SpeedDemoClass {
static int iterations=0;
static int incrementor=10000000;
public static void main(String[] args) {
while(incrementor>1){
try{
iterations=iterations+incrementor;
iterator(iterations);
}
catch(Exception e){
System.out.println("So this is the limiting error: "+e);
iterations=iterations-incrementor;
incrementor=incrementor/10;
iterations=iterations+incrementor;
}
}
System.out.println("The upper limit of iterations is: "+iterations);
}
public static void iterator(int a){
long start_time= System.currentTimeMillis();
StringBuilder sbuild= new StringBuilder("JAVA");
for(int i=0;i<a;i++){
sbuild.append("JAVA");
}
System.out.println("Performing "+a+" append operations;"
+"process completed in :"
+(System.currentTimeMillis()-start_time)+"ms");
}
}
Did you try to compile it?
Of course it doesn't work
Here is a brief description of what I'm trying to do!
I am trying to do the following:
- Initialize incrementor = 10000000 and iterations = 0 and pass the result incrementor = incrementor + iterations iterator () .
- , , * ** incrementor, incrementor 10, li >
- 1 2, .
- , , ,
(.. 0)
, 92274686. . , , , . , - , .