Y
yawnmoth
public class Test01
{
public static void main() {
try {} catch (java.io.IOException e) {}
}
}
When I run that, I get the following:
Test01.java:4: exception java.io.IOException is never thrown in body
of corresponding try statement
try {} catch (java.io.IOException e) {}
^
1 error
My question is... why? Giving a syntax error over this seems about
as appropriate as giving a syntax error for "if (false)". In both
cases, although it may not serve a lot of point in a finished product,
it may be useful for debugging. If I comment out a line that may
(conditionally) throw java.io.IOException, it's annoying having to
comment out a whole slew of other lines, as well. Same thing for "if
(false)". That's easier than commenting out the whole if statement
(especially if there aren't any else's present).
{
public static void main() {
try {} catch (java.io.IOException e) {}
}
}
When I run that, I get the following:
Test01.java:4: exception java.io.IOException is never thrown in body
of corresponding try statement
try {} catch (java.io.IOException e) {}
^
1 error
My question is... why? Giving a syntax error over this seems about
as appropriate as giving a syntax error for "if (false)". In both
cases, although it may not serve a lot of point in a finished product,
it may be useful for debugging. If I comment out a line that may
(conditionally) throw java.io.IOException, it's annoying having to
comment out a whole slew of other lines, as well. Same thing for "if
(false)". That's easier than commenting out the whole if statement
(especially if there aren't any else's present).