package javaapplication1;
public class JavaApplication1 {
public static void main(String[] args) {
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
int n = 0;
for (int j = 0; j < 100; j++) {
if (j != 0) {
n += 10 / j;
//System.out.println(n);
}
}
}
long t2 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
int n = 0;
for (int j = 0; j < 100; j++) {
try {
n += 10 / j;
// System.out.println(n);
} catch (Exception e) {
//System.out.println(e);
}
}
}
long t3 = System.currentTimeMillis();
System.out.println("if: " + (t2 - t1));
System.out.println("try - catch:" + (t3 - t2));
}
}
/*
run:
if: 310
try - catch:340
*/