aspose file tools
The moose likes Beginning Java and the fly likes syntax help please Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "syntax help please" Watch "syntax help please" New topic
Author

syntax help please

Jacob Rich
Greenhorn

Joined: Jan 02, 2007
Posts: 27
This is my code:
and im getting this error when compiling:

C:\Documents and Settings\Zack>javac shuffle.java
shuffle.java:18: '}' expected
^
1 error


Anyone know what the problem could be?


~"Great is the art of beginning, but greater is the art of ending."~
Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
You are missing closing braces "}" after
class shuffle {
public static void main (String[] args) {
int x = 3;
while (x > 0) {
x = x - 1;
System.out.println("-");
if (x > 2) {
System.out.print("a");
}// end of IF
if ( x == 2) {
System.out.print("b c");
}// end of IF
if ( x == 1 ) {
System.out.print("d");
x = x - 1;
} // Missing
}
}
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16692
    
  19

Generally, when the compiler is complaining about a missing closing brace, you miss the brace much earlier in the code. And the compiler is mismatching the braces.

Go to line 18, and work backwards. You will see that one of your "if" statements has an open brace, but no closing brace.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jacob Rich
Greenhorn

Joined: Jan 02, 2007
Posts: 27
ah... thanks guys.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: syntax help please
 
Similar Threads
Pelase Help me out imme....
Another Question from the book "Head First Java"
Really beginner question
Exception in thread "main"
While loop - Head's First Java example