• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dr Java says cannot find symbol  RSS feed

 
Aamir Wreoh
Greenhorn
Posts: 1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm really really new here and I usually use Eclipse when I code but I'm using Dr Java right now and I compiled it and it says "cannot find symbol" in a Boolean expression where there clearly is a symbol.. It's in the line with the second monkeyanswer. What does it mean?

I'm support to "Write a program that generates four random integers between -3 and 3 (inclusive at both ends) and stores them in four variables. Display the four numbers and their sum. If the sum is less than zero then display "Negative" else display "Not Negative."

Here's my code (I thought I was done) if anyone can help:

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags for you, doesn't it look better?

From that it can clearly see that the if statement is out of scope (outside the constructor where the rest of the logic is) getting the compiling error you've seen.

Also the random number generation does not use the user's input at all because I don't see a "scan.getInt()" anyway.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:... the if statement is out of scope (outside the constructor where the rest of the logic is) ...

And those braces make it an instance initialiser.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!