The first one:
for (i = 0; i < 100; i++)
{
try { n = s.pop(); }
catch (EmptyStackException e) { . . . }
try { out.writeInt(n); }
catch (IOException e) { . . . }
}
The second one:
try
{
for (i = 0; i < 100; i++)
{
n = s.pop();
out.writeInt(n);
}
}
catch (IOException e) { . . . }
catch (EmptyStackException e) { . . . }
I know that usually we use the second type of handling but I am trying to understand why it's better.