Static field, constructor and exceptionTag(s): Language
Consider the following class
public class Foo {
private static Bar b = new Bar();
...
}
class Bar {
public Bar ( ) throws Exception {
}
}
To solve this situation, use a static block.
public class Foo {
static Bar bar ;
static {
try {
bar = new Bar() ;
}
catch ( Exception e ) {
e.printStackTrace() ;
}
}
}
class Bar {
public Bar ( ) throws Exception {
}
}
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com