• Post Reply Bookmark Topic Watch Topic
  • New Topic

error: expected ';' at end of JOptionPane method  RSS feed

 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am putting together my first swing program and while I followed the syntax in my book exactly I am getting an error regarding using an integer variable.



GreedGame.java:105: ';' expected
winningScore = Integer.parseInt(JOptionPane.showInputDialog)("Pl
ease enter score needed to win game (without commas or decimal points): ");
^
1 error



the code I have:



my import is as such: above the public class



Is there something I am missing?
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your () are paired incorrectly. You have one ) too many after showInputDialog, and probably one too few before the ;
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The () inside the quotes are causing the problem? I have both open and closing (). Do I need to escape them with \?
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Hultin wrote: The () inside the quotes are causing the problem?


No. The ones outside the quotes.

Why not look at your code while thinking of what it should look like? What kind of parameters does the Integer.parseInt()
method take? And does your code pass that kind of parameters? It's not just a matter of throwing parentheses at the code
until it compiles.
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I took the () out of the line of code as you suggested but I get the same error:



Any thoughts?
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't see anything wrong with this piece of code?
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My book tells me that is exactly correct, not to say all books are right. My javascript book was full of errors.
 
Pari Nanoti
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcourse there's a misprint in the book, It's time you should compile the java program in your brain while you are writing it.




I mean, look at the code, the problem is right there, in front of your eyes.

Hint: Apply your basic, very very very basic java sense.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break down the method call. What are you calling first, and what are you passing to which method? A hint: you are using the result of JOptionPane.showInputDialog as an argument to Integer.parseInt.

Since the problem is not related to GUIs or Swing but to Java syntax I'm moving this thread to Beginning Java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!