|
-
Apr 3rd, 2001, 08:38 PM
#1
Thread Starter
Dazed Member
I read somewhere that instance fields are initialized
in constructor methods. But class fields are actually
initialized in a method that is hidded from the Java programmer. If one disassembles the Java byte codes in a Java class file one can see the class initialization code in a method name <clinit>
Ok fine so this leads me to my question is the main purpose of a static initializer to initialize class fields to a value other then the default false or zero?
or is static just a short hand was of defining a block
of static class fields without specifying the static keyword for each and every class field.
class test {
static {
double x = 1.5;
int k = 5654;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|