Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: Re: I don't why I get 'not a statement' error in the following code... Date: Wed, 05 Oct 2011 12:00:18 -0700 Organization: Canadian Mind Products Lines: 54 Message-ID: References: Reply-To: Roedy Green NNTP-Posting-Host: RCd/Ul4tyxGUBII8WGwa5g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8579 On Tue, 4 Oct 2011 11:16:22 -0700 (PDT), Chad wrote, quoted or indirectly quoted someone who said : >public class hw1q3 { Class name must start with capital letter. See http://mindprod.com/jgloss/codingconventions.html > > 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 Test.x is a variable. You have to do something with it, e.g. pass it as a parameter, add 1 to it. . > } >} > >class Test { > > public static final int w = 1; > public static int x = 2; > public final int y = 3; > public int z = 4; is real life you never expose your variables like that. You use a getter/setter. > > 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); > } >} -- Roedy Green Canadian Mind Products http://mindprod.com It should not be considered an error when the user starts something already started or stops something already stopped. This applies to browsers, services, editors... It is inexcusable to punish the user by requiring some elaborate sequence to atone, e.g. open the task editor, find and kill some processes.