@@ -0,0 +1,1849 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage bzh.ys.javabyexample.language.conversion;%0A%0A/**%0A *%0A * @author yannig%0A */%0Apublic class Test %7B%0A    %0A    // concat is evil in a loop !%0A    public static String testConcat() %7B%0A       String test = %22%22;%0A        for (int i = 0; i %3C 10000; i++) %7B%0A            test += i; // or test.concat( Interger.toString(i) )%0A        %7D %0A        %0A        return test;%0A    %7D%0A    %0A    public static String testBuffer() %7B%0A       StringBuilder test = new StringBuilder();%0A        for (int i = 0; i %3C 10000; i++) %7B%0A            test.append(i);%0A        %7D %0A        %0A        return test.toString();%0A    %7D%0A    %0A    public static String testOldBuffer() %7B%0A       StringBuffer test = new StringBuffer();%0A        for (int i = 0; i %3C 10000; i++) %7B%0A            test.append(i);%0A        %7D %0A        %0A        return test.toString();%0A    %7D%0A    %0A    public static void convertionExample() %7B%0A        int i = 10;%0A        %0A        // Bad%0A        String convert1 = %22%22 + i;%0A        %0A        // Too long%0A        Integer j = new Integer(i); // Wrapper of int%0A        String convert2 = j.toString();%0A        %0A        // Use the Wrapper methods%0A        String convert3 = Integer.toString(i); // exists for Long, Float, Double, Character, ...%0A    %7D%0A    %0A    public static void booleanWrapper() %7B%0A        // Ugly%0A        Boolean test = null;%0A        %0A        // 3 states for a boolean oO be carefull with Boolean%0A        if ( test == null ) %7B%0A            %0A        %7D%0A        else if ( test ) %7B%0A        %0A        %7D%0A        else %7B%0A        %0A        %7D%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        testConcat(); // Profiler said 341ms%0A        testOldBuffer(); // Profiler said 1.71ms%0A        testBuffer(); // Profiler said 0.56ms !!!!%0A        %0A        convertionExample();%0A    %7D%0A    %0A%7D%0A

test on concat and convert