Tahir!
The code that you have written is not correct.
You are missing the class declaration statement and the opening parenthesis that goes with it.
Re-write the code as:
Okay, now lets take a look at the problem.
"x" is declared is final instance constant, hence it must be assigned a value in an initializer, or in every constructor.
So, try initializing x in either instance initializer or in the constructor before you try to access "x" in the System.out.println statement.
I hope this helps.
Oh! One more thing that I forgot to mention is you cannot declare variables outside the class/interface body. Sorry no C/C++ tricks to declare/initialize global constants before the class declaration. It does not work in
Java.
[ February 07, 2002: Message edited by: Brian Lugo ]