Name: ###@###.### Date: 09/05/96
compiler do not permit to declare an exception parameter
of the same name as a variable from the embracing block
though there is no prohibition in the Java Language Specification.
Moreover such declaration is in effect only within a catch block.
So it would be reasonably to suppose that it would screen the
declaration of the same name variable from the embracing block.
Tests: compilation of the following test
public class test
{
public static void main(String argv[])
{
float zero = 0.0f, e;
try {
e = zero / zero;
} catch (ArithmeticException e) {
System.out.println(e.getMessage());
}
}
}
produces such error diagnostics:
novo40% javac test.java
test.java:9: Variable 'e' is already defined in this method.
} catch (ArithmeticException e) {
^
1 error
======================================================================