Short Java error

  • Thread starter bomba923
  • Start date
  • #1
bomba923
760
0
What does an " ')' expected " error signify? How did I not use parentheses correctly?

The error is in this line:

System.out.println(num1 + " " + num2 + " " + num 3 + " " + num4 + " " + num5) ;

What possible mistake can there be in parentheses?
 

Answers and Replies

  • #2
Hurkyl
Staff Emeritus
Science Advisor
Gold Member
14,967
19
Such errors can often be symptoms of other syntactic mistakes. An error on a previous line could do it, but I bet it's really that nifty space you have between `num' and `3'.
 
  • #3
bomba923
760
0
The program is, as follows:
-----------------------------------
import javax.swing.JOptionPane ;

public class DigitSpacer {

public static void main(String args[]) {

String input;
int num0;
int num1;
int num2;
int num3;
int num4;
int num5;

input = JOptionPane.showInputDialog("What is the number?");

num0 = Int.parseInt(input);

num1 = Math.floor(num0 / 10000);

num2 = Math.floor((num0 - 10000 * num1) / 1000);

num3 = Math.floor((num0 - 10000 * num1 - 1000 * num2 ) / 100);

num4 = Math.floor( (num0 - 10000 * num1 - 1000 * num2 - 100 * num3 ) / 10);

num5 = num0 - 10000 * num1 - 1000 * num2 - 100 * num3 - 10 * num4 ;

System.out.println( num1 + " " + num2 + " " + num 3 + " " + num4 + " " + num5 );

System.exit(0);

}//main
}//DigitSpacer
--------------------------------------------------------
The only error is that "')' expected error" for some reason
regarding the line with System.out.println

*In another trial, I deleted the spaces, but I keep getting the same error!
 
  • #4
Hurkyl
Staff Emeritus
Science Advisor
Gold Member
14,967
19
I still think it's the space between `num' and `3'.
 
  • #5
bomba923
760
0
Ohhh--->that space?

How can I fix that? :redface:
 
  • #6
Hurkyl
Staff Emeritus
Science Advisor
Gold Member
14,967
19
Well, you place your cursor just to the left of the three (and thus to the right of the offending space), and press your backspace key! :biggrin:
 
  • #7
bomba923
760
0
Many thanks! :smile:

Indeed that was the error!
 
Last edited:

Suggested for: Short Java error

Replies
14
Views
125
Replies
4
Views
333
  • Last Post
Replies
19
Views
1K
Replies
1
Views
2K
Replies
10
Views
452
Replies
23
Views
4K
  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
10
Views
1K
Top