Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

syntax help please

 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21506
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah... thanks guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic