Re: final variables in constructors (OT)

1999-07-17 Thread Kontorotsui
Ok, if declared as final and static, variables behave just like constants and can be used in constructors. I don't know how it happened the first time that it didn't work, but after another test it's confirmed, they work. With an afterthough, it would have been a big mistake in the java languag

Re: final variables in constructors (OT)

1999-07-16 Thread Nick Lawson
The java language specification is a little difficult to follow on final static fields. The best place to look is 13.4.8 - Binary Compatability. This says "We call a field that is static, final, and initialized with a compile-time constant expression a primitive constant." and it is impl

Re: final variables in constructors (OT)

1999-07-16 Thread Chris Abbey
At 11:05 AM 7/16/99 +0200, Kontorotsui wrote: > >On 14-Jul-99 Michael Sinz wrote: >> The reason is that until the constructor is called, no instance data >> can be used. Note that you did not make this static final but rather >> final. This means there must be actual instance data to access this

Re: final variables in constructors

1999-07-15 Thread David D. Lucas
Kontorotsui wrote: > > aClass extends aSuperClass > { > final int v = 1; > > aClass() > { > super(v); > } > } First off, my understanding of the question is why doesn't v exist when passed into super. "super" is not a method call like everything else. It is a special keyword and a

Re: final variables in constructors

1999-07-15 Thread Pavel Tolkachev
The answer is: according the JLF, superclass constructor is called *before* any initialization statement in subclass. super() does not actually run in aClass() but java compiler generates method where it is called before first initialization statement of aClass. The syntax super(...) is allowed o

RE: final variables in constructors

1999-07-14 Thread Harold G. Andrews II
Have you tried using "static final int v = 1;" instead? -Andy > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Kontorotsui > Sent: Wednesday, July 14, 1999 12:41 PM > To: [EMAIL PROTECTED] > Subject: final variables

final variables in constructors

1999-07-14 Thread Kontorotsui
I wonder why if I write this: aClass extends aSuperClass { aClass() { super(1); } } where the superclass is: aSuperClass { aSuperClass(int i) { ... } } anything works ok. If instead I write aClass extends aSuperClass { final int v = 1; aClass() { super(v);