posted 24 years ago
in your first case, u have a blank final class variable.
It must be assigned a value in a static initializer.
the second program is a very good code... where'd u get it from ?
The anonymous sub class being created in testers.add( new tester() { }); must throw an IOException in its constructor, coz its super class, i.e tester throws an IOException.
However, anonymous classes cannot have constructors, therefore my conclusion is :
Its not possible to create an anonymous subclass of a class that throws a checked exception in its constructor which takes no parameters.
More generally, it is not possible to create an anonymous subclass that calls any constructor of its superclass which throws a checked exception.