• Post Reply Bookmark Topic Watch Topic
  • New Topic

<identifier> expected?  RSS feed

 
Tiffany Walker
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again folks. I have an error that I can't figure out. Here's my but of code, I can post the whole thing if necessary, but the program is getting big.


I'm getting the error on the NUMBER_OF_RECORDS = JOptionPane....
I don't understand why. Even if I put the type ahead of the code (String) I get the error anyway. What am I doing wrong?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiffany Walker wrote:I don't understand why. Even if I put the type ahead of the code (String) I get the error anyway. What am I doing wrong?

Bit tough to tell from just that snippet. Could you post the actual error message, and (unless it's ridiculously long) the actual code including your import statements?

Winston
 
Tiffany Walker
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Winston,

I figured that one out. A different board told me that call JOptionPane outside of a method.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiffany Walker wrote:
I figured that one out. A different board told me that call JOptionPane outside of a method.

Please read http://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiffany Walker wrote: . . . A different board told me that call JOptionPane outside of a method.
What does that mean?

How do you manage to get an <identifier> expected error from that code? You can get an “incompatible type, found String expected int”, error, because you are returning a String and should use something like Integer.parseInt() to convert it, but I can’t see how you get <identifier> expected there.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Tiffany Walker wrote: . . . A different board told me that call JOptionPane outside of a method.
What does that mean?

How do you manage to get an <identifier> expected error from that code? You can get an “incompatible type, found String expected int”, error, because you are returning a String and should use something like Integer.parseInt() to convert it, but I can’t see how you get <identifier> expected there.

You do get that error if that line of code is not inside a method.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Joanne. I thought it means you ought to have JOptionPane outside a method. Misunderstood completely.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!