// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class IntegerTest {
    private static final int N = 100000000;

    private static void test() {
        long start1 = System.currentTimeMillis();
        for (int i = 0; i < N; i++) {
            boolean tal = test1("12345");
        }
        long stop1 = System.currentTimeMillis();
        long start2 = System.currentTimeMillis();
        for (int i = 0; i < N; i++) {
            boolean tal = test2("12345");
        }
        long stop2 = System.currentTimeMillis();
        System.out.println("test 1 (static)  = " + (stop1 - start1));
        System.out.println("test 2 (new)  = " + (stop2 - start2));
    }
    private static boolean test1(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    private static boolean test2(String s) {
        try {
            new Integer(s);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    public static void main(String[] args) {
        test();
    }
}
