static final int, but constructor with (final int) arguments
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've got a class constructor which takes two final int arguments; they
come from the CLI and this one is parsed only once, at the beginning
of the programming. Once they have been parsed from the CLI, errors
handled, etc., they never change.
During the program's execution, I need to create two objects from this
class. These objects thus inherit some variables that need to be static final
int. However, the final is not accepted because, in the constructor, I
evidently define one of these variable's values.
To take an example, consider the class foo. You know that
==
public class foo {
private static final int c;
public Foo(final int a, final int b) {
c = 2*a;
}
}
==
will produce an error because c cannot be modified. I can understand
it, and I thus tried to put the final keyword in the constructor, just
before `c', but to no avail. I tried various combinations, using
static blocks, etc., but nothing more.
Do you have any reasonable way to achieve this?
Thanks.
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --
All that glisters is not gold. (William Shakespeare)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iEYEARECAAYFAk2QwVoACgkQM0LLzLt8MhzGXACeIIkj56gKublen9HTMvl8CyCw
xT0AoIthZ3lemIugE7Z9ROc1RK6gUuOU
=8UVh
-----END PGP SIGNATURE-----