Hi,
Originally posted by Thomas De Vos:
A "Blank" final variable has to be initialized before it is used, be it in the constructor or somewhere else in the code.
I think blank final variables have
always to be initialized, even if they are not used. They are implicitly initialized but an assignment before the end of the constructor is required (see the code below)
class A {
A(){foo();}
void foo(){}}
public class B extends A {
final int i;
B(){i=10;
}
void foo(){
System.out.println("i: " + i
);
}
public static void main(String [] args) {
B t = new B();
t.foo();
}
}
Greetings,
Gian Franco
[ March 22, 2004: Message edited by: Gian Franco Casula ]