SCJP 1.4, SCBCD 1.3
java amateur
SCJP 1.4, SCBCD 1.3
but my question is according to this statement
"Instance initializers in annonymous classes can throw exception."
there should not be any errors on compiling and how can I declare that instance initializer will throw an exception for no compilation error??
A given anonymous class is only instantiated at a single point in a program. It is therefore possible to directly propagate information about what exceptions might be raised by an anonymous class' instance initializer to the surrounding expression
java amateur
Originally posted by miguel lisboa:
[...] so i refactored to this, which you can try: [...]
java amateur
Originally posted by miguel lisboa:
i guess i do both, else pls correct me
Object a = new Object() {{FileInputStream fis = new FileInputStream("file.txt");}};
java amateur
so, btw, what's the name of what i coded? is it just an inner (annonymous) class?
java amateur
java amateur