Salida confusa de recursión infinita dentro de try-catch

Considere el siguiente código.

public class Action {
private static int i=1;
public static void main(String[] args) {
    try{
        System.out.println(i);
        i++;
        main(args);
    }catch (StackOverflowError e){
        System.out.println(i);
        i++;
        main(args);
    }
 }

}

Estoy obteniendo valoro hasta4338 correctamente. Después de atrapar elStackOverflowError La salida se conecta de la siguiente manera.

4336
4337
4338 // up to this point out put can understand 
433943394339 // 4339 repeating thrice  
434043404340
4341
434243424342
434343434343
4344
4345
434643464346
434743474347
4348
434943494349
435043504350

ConsiderarVivir demo aquí Está funcionando correctamente hastai=4330. En realidad, ¿cómo sucedió esto?

Para tu información:

Hice el siguiente código para darme cuenta de lo que está pasando aquí.

public class Action {

    private static int i = 1;
    private static BufferedWriter bw;

    static {
        try {
            bw = new BufferedWriter(new FileWriter("D:\\sample.txt"));
        } catch (IOException e) {
           e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {
        bw.append(String.valueOf(i)+" ");
        try {
            i++;
            main(args);
        } catch (StackOverflowError e) {
            bw.append(String.valueOf(i)+" ");
            i++;
            main(args);
        }
    }

}

Ahora el número anterior no está allí. ahora valor dei hasta16824744 Corregir y y sigue corriendo. Estoy saltando esto puede correr hasta el valor dei=2,147,483,647(valor máximo de int) sin problema.

Hay algún problema conprintln(). Hay respuestas similares a continuación también. ¿Pero por qué?

¿Cuál será la razón real?

Respuestas a la pregunta(7)

Su respuesta a la pregunta