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);
}
}
with the same superclass, I get a "Can't reference v before the superclass
constructor has been called." error from the compiler.
I understand that in general a variable cannot be referenced before the
superclass constructor was called, but if that variable is a final, then it's a
constant, why does the compiler complains?
The two pieces of code are, semanthically, the same, aren't they?
The javac pre-processor could even substitute the constant values before
compiling!
It's the java language that is excessively pedantic or there is something I'm
missing?
---
Andrea "Kontorotsui" Controzzi - MALE Student of Computer Science at
University of Pisa - Italy - E-mail: [EMAIL PROTECTED]
My home page: http://www.cli.di.unipi.it/~controzz/intro.html
Founder and Admiral of Hoshi no Senshi (italian Leiji Matsumoto's fan group).
Creator of It.Arti.Cartoni (italian anime newsgroup) and proud member of...
+-------------------------------------------------------------+
| . * . |
| . __ . . |
| oq | po _ _ |
| / #==>>>==# ,-' (_)\ |
| | ,-|~\\ ///_ ,() ,_____} |
| | |/|~]]] /// ,-~' .,~ / \| . |
| |\_|_|_\_\~~----~~' \ ( /| . |
| . /~ \___/ [m] \ \__// |
| _bo..__ // `-,.~~ |
| _-~ 0000000000000ooooo.__ ( . |
| \ 000000000000000000000000o . |
| . (_)0000000000000000000000 |
| . \~~~*,,,* ~000000000000000000 |
| ~0000000000000 . |
| ~~~---~~ |
| .* |
+-------------------------------------------------------------+
| An e-mail network of Space Cruiser Yamato and |
| StarBlazers Fans |
+-------------------------------------------------------------+
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]