Java Reference
In-Depth Information
{
System.out.println(e);
}
}
//...
}
stantiate the class that describes Java's JDBC-ODBC Bridge Driver, and to register
a
JDBCFilterDriver
instance with Java's database driver. Although this listing's
JDBC-orientedcodeisprobablymeaninglesstoyourightnow,thelistingillustratesthe
A class can declare a mix of class initializers and class field initializers, as demon-
strated in
Listing 2-17
.
Listing 2-17.
Mixing class initializers with class field initializers
class C
{
static
{
System.out.println("class initializer 1");
}
static int counter = 1;
static
{
System.out.println("class initializer 2");
System.out.println("counter = "+counter);
}
}
field initializer. When the Java compiler compiles into a classfile a class that declares
atleastoneclassinitializerorclassfieldinitializer,itcreatesaspecial
void <clin-
it>()
classmethodthatstoresthebytecodeequivalentofallclassinitializersandclass
field initializers in the order they occur (from top to bottom).