Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8538
| From | Chad <cdalten@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | I don't why I get 'not a statement' error in the following code... |
| Date | 2011-10-04 11:16 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <de7d2141-f562-452d-b754-46cab58ef211@d18g2000yql.googlegroups.com> (permalink) |
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
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
I don't why I get 'not a statement' error in the following code... Chad <cdalten@gmail.com> - 2011-10-04 11:16 -0700
Re: I don't why I get 'not a statement' error in the following code... Patricia Shanahan <pats@acm.org> - 2011-10-04 11:33 -0700
Re: I don't why I get 'not a statement' error in the following code... Chad <cdalten@gmail.com> - 2011-10-04 11:43 -0700
Re: I don't why I get 'not a statement' error in the following code... markspace <-@.> - 2011-10-04 12:14 -0700
Re: I don't why I get 'not a statement' error in the following code... Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-04 12:20 -0700
Re: I don't why I get 'not a statement' error in the following code... Chad <cdalten@gmail.com> - 2011-10-04 14:55 -0700
Re: I don't why I get 'not a statement' error in the following code... Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-04 15:09 -0700
Re: I don't why I get 'not a statement' error in the following code... Chad <cdalten@gmail.com> - 2011-10-04 15:11 -0700
Re: I don't why I get 'not a statement' error in the following code... Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-04 17:30 -0700
Re: I don't why I get 'not a statement' error in the following code... Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-05 01:19 +0300
Re: I don't why I get 'not a statement' error in the following code... Patricia Shanahan <pats@acm.org> - 2011-10-04 22:16 -0700
Re: I don't why I get 'not a statement' error in the following code... Chad <cdalten@gmail.com> - 2011-10-05 08:13 -0700
Re: I don't why I get 'not a statement' error in the following code... Patricia Shanahan <pats@acm.org> - 2011-10-05 10:21 -0700
Re: I don't why I get 'not a statement' error in the following code... Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-05 20:43 -0400
Re: I don't why I get 'not a statement' error in the following code... markspace <-@.> - 2011-10-05 19:36 -0700
Re: I don't why I get 'not a statement' error in the following code... Lew <lewbloch@gmail.com> - 2011-10-05 19:43 -0700
Re: I don't why I get 'not a statement' error in the following code... Roedy Green <see_website@mindprod.com.invalid> - 2011-10-05 12:00 -0700
csiph-web