Originally posted by Dinesh Tahiliani:
1. package test1;
2. public class Test1 {
3. static int x = 42;
4. }
1. package test2;
2. public class Test2 extends test1.Test1 {
3. public static void main(String[] args) {
4. System.out.println("x = " + x);
5. }
6. }
Hello,
I have now corrected the line.
Can anyone now expalin me why its failing.
What did you change exactly ? Did you just copy the line I put in bold, which I copied from you myself? You simply copied the same line over...
The point was
x is declared with a
package modifier.
Your classes Test1 and Test2 are not in the same package, so Test2 cannot see
Test1.x.
One solution would be to declare
x with a
protected or
public modifier.
I'm sorry to say, I find very frustrating the little effort you seem to put before posting. I'll let other posters answer you.
Alex
[ March 04, 2008: Message edited by: Alex Belisle Turcot ]