File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Error - not a statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error - not a statement" Watch "Error - not a statement" New topic

Error - not a statement

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Quick question....I keep getting error saying not a statement to the following code section. The below is not my whole code, but that is the part I am getting an error least for now. Can anyone tell me what I have it the () or something inside. I am probably just missing it.

Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Holly,

[ October 20, 2004: Message edited by: Joyce Lee ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Count your parentheses as you scan from left to right. Start with 0 and for each ( add 1 and for each ) subtract 1. When you get to the end of the statement, if you aren't at 0, you have a problem.Check the other lines though, too.
[ October 20, 2004: Message edited by: David Harkness ]
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Great Thank you for that help!! Kinda dumb huh?? LOL. Oh well. Now on to the hard stuff for me. I am in the process of learning about methods and so on, so what kinda of tips can you give me for the following code. And trust me I know I have tons of erros, I just dont have anyone to help me out. The people in my class wont study or anything so I come here to look for some guidance. So thank you in advance for any help you may can give. Thanks!

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
I think one of the main problems is the the variables i declare in the beginning of public static void main( String[] args ). Is that right? I think that may be why I am getting the errors, what do yall think?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

You have to specify a type when you declare a variable, so, for example, you have to say "int customercount = 0;".

Later on, I see you using "usage" without having declared it anywhere, either. Every variable's type has to be specified either before you use it altogether, or when it is first assigned to.

[Jess in Action][AskingGoodQuestions]
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Ok great thanks...I will get to work on that. I really appreciate the help!!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
"so what kinda of tips can you give me for the following code."

Break everything down to individual tasks, then work on one at a time
write a program to get customer numbers (with an exit routine)
compile/run - you will discover an error at "showInputDiaolg("

when this is working, include getting kwh
complie/run/fix/compile/run etc

add findCharge()
test, when OK
add increments to cumulatives
add output method
when OK
feet up, take a break.
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Ok great I got it to compile so now I need to work on the JTextArea cause obviously that is not right...huh? At least I am getting there.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211


If I were you, I'd pay close attention to what Michael is saying.
Try to work out a code-compile-test-debug cycle.
Write the minimum amount of code that you need to (maybe as little as 3 or 4 lines), compile it, run it, fix any errors before you go back to writing more code.
This is something that will help you now, when learning how to program, and later when you are doing real life coding.


The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Ok I will for sure do that for now on, I see how much easier that is than throwing something together and going now what. So I apprecaite that and I will do that for now on, that way I will know what the problem is and be able to go right to the problem. Thanks!!
Jeff Langr
Ranch Hand

Joined: May 14, 2003
Posts: 799
One more recommendation: use constants with meaningful names instead of "magic numbers" in your code. What does 300 mean, or 0.9, or 0.8?

Consider something like:

Obviously you could eliminate a bunch more magic numbers and magic expressions, and I was guessing at the meaning of the ones I did eliminate. There's still a lot more you could do to simplify the logic here. The goal is to make your code so that someone else can read and understand what it does and what it means. Also, simplifying things in this manner will often help point out mistakes that might otherwise be difficult to find.

[ October 21, 2004: Message edited by: Jeff Langr ]

Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
I agree. Here's the link:
subject: Error - not a statement
It's not a secret anymore!