C
Chad
public class hw1q3 {
public static void main(String[] args) {
Test a = new Test();
a.showAllOne();
a.showAllTwo();
System.out.println("The value of x is " + Test.x); //I get x
is 2
Test.x; //I get a compile error that says - not a statement
}
}
class Test {
public static final int w = 1;
public static int x = 2;
public final int y = 3;
public int z = 4;
public void showAllOne() {
System.out.println("w is " + w);
System.out.println("x is " + x);
System.out.println("y is " + y);
System.out.println("z is " + z);
}
public static void showAllTwo() {
System.out.println("w is " + w);
System.out.println("x is " + x);
//System.out.println("y is " + y);
//System.out.println("z is " + z);
}
}
I don't get why 'Test.x;' in main() isn't a variable. The expression
'Test.x' ends with a semicolon. So I just assumed it was a valid
statement. However, the java compiler tells me something different.
Ideas? Possible hints?
Chad
public static void main(String[] args) {
Test a = new Test();
a.showAllOne();
a.showAllTwo();
System.out.println("The value of x is " + Test.x); //I get x
is 2
Test.x; //I get a compile error that says - not a statement
}
}
class Test {
public static final int w = 1;
public static int x = 2;
public final int y = 3;
public int z = 4;
public void showAllOne() {
System.out.println("w is " + w);
System.out.println("x is " + x);
System.out.println("y is " + y);
System.out.println("z is " + z);
}
public static void showAllTwo() {
System.out.println("w is " + w);
System.out.println("x is " + x);
//System.out.println("y is " + y);
//System.out.println("z is " + z);
}
}
I don't get why 'Test.x;' in main() isn't a variable. The expression
'Test.x' ends with a semicolon. So I just assumed it was a valid
statement. However, the java compiler tells me something different.
Ideas? Possible hints?
Chad