Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

<identifier> expected  RSS feed

 
Aneeqa Rustam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my code keeps saying identifier expected and I really don't know why, any suggestions?

Here's my code:

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: Your line number 44-70 are not inside the constructor block (curly braces)
 
Swastik Dey
Rancher
Posts: 1782
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your complete syntax appearing to be wrong. What is button1, button2 etc? You should add listener from within any method. But this appearing after closing the bracket. I have just corrected the syntax, have a look.''

 
Campbell Ritchie
Sheriff
Posts: 53764
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You appear not to have read the post where I showed you how to add an action listener. You can see a better way to get the {} matched up in a post I wrote when I had only been here a few weeks.
 
Aneeqa Rustam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You appear not to have read the post where I showed you how to add an action listener. You can see a better way to get the {} matched up in a post I wrote when I had only been here a few weeks.


Here is my code now but when I click compile and this comes up "local variable referenced from an inner class must be final or effectively final"

 
Campbell Ritchie
Sheriff
Posts: 53764
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, mark the local variables final. You know you must not then try to reassign them.
 
Aneeqa Rustam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Well, mark the local variables final. You know you must not then try to reassign them.


how do i make them final? Thank you for helping me btw!
 
Campbell Ritchie
Sheriff
Posts: 53764
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the keyword final before the declaration of whichever local variable you are using in the anonymous class.
 
Campbell Ritchie
Sheriff
Posts: 53764
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way: why are you altering the alignments of that label in the action performed method?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!