Do you have a big taxing for loop
Does you program have very big for loops that it has to run through always? Are these loops making your program slower? Here is a method to over come it.
Lets just consider that you program requires to go through a for loop a million times, this means that there are a million conditions checked (for the loop to go on).
Lets just consider that you program requires to go through a for loop a million times, this means that there are a million conditions checked (for the loop to go on).
for(long i=0;i<=list.size();i++)
{
System.out.println(list.get(i).name);
}
This is very taxing on any application. So here what you can do
try
{
long i=0;
while(true)
{
System.out.println(list.get(i).name);
i++;
}
}
catch(ArrayIndexOutOfBounds e)
{
//don’t handle the exception
}
Isn’t it simple?
0 Comments:
Post a Comment
<< Home