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

Head First Java - Beat Box code - missing variable?

 
Brian Altman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I found the error.

Thanks anyway!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Get rid of the semicolon at the end.

 
Brian Altman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply Jeff!

My eyes were going crazy from looking over that code.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Altman, please do not delete or modify the original question after you resolve an issue you were facing (either yourself or by help of other Ranchers). For someone who might read the thread later it can seem strange seeing answer(s) without any information about the original problem.

Welcome to the Ranch!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Altman wrote:Thanks for the quick reply Jeff!

My eyes were going crazy from looking over that code.


That extra semicolon can be hard to spot. What made it easy was the error message. It said the variable "i" wasn't defined, but obviously it was, so we must have been out of i's scope, so we look for what that scope actually is, then end result of which must be that either there's a semicolon, as you had, or there isn't, but we're referring to "i" after the for loop's closing } brace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic