What’s the Output?
Determine the output of the following program. (Code is from a 1997 JavaWorldarticle by Bill Venners.)
public class Ball extends Exception {} public class Pitcher { private static Ball ball = new Ball(); static void playBall() { int i = 0; while (true) { try { if (i % 4 == 3) { throw ball; } ++i; } catch (Ball b) { i = 0; System.out.println("Reset"); } } } public static void main(String[ ] args) { Pitcher.playBall(); } }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.