Consider the case in which >, == and >= operator are used for comparison.
long starttime = System.currentTimeMillis();
for (int i = 0; i < 8888888; i++) {
if (i == 10 || i < 10) {
}
}
System.out.println(“Total time taken case1″+(System.currentTimeMillis()-starttime));
starttime = System.currentTimeMillis();
for (int i = 0; i < 8888888; i++) {
if (i <= 10) {
}
}
System.out.println(“Total time taken case2″+(System.currentTimeMillis()-starttime));
Output is :
Total time taken case1 31ms
Total time taken case2 16ms
Just try to use code efficiently.
No comments:
Post a Comment