permaculture playing cards*
The moose likes Beginning Java and the fly likes error: cannot find symbol, help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error: cannot find symbol, help!" Watch "error: cannot find symbol, help!" New topic
Author

error: cannot find symbol, help!

Glen Richard
Greenhorn

Joined: Mar 08, 2013
Posts: 6


I am running into the error of:

error: cannot find symbol

This is on each variable I have : mexicoPop, MexicoPopFin, usPop, Years


What have I done wrong? Such a beginner mistake I'm sure...

Also any critique on if this program is even gonna work will be great!!!


[HENRY: Fixed Code Tags]
Glen Richard
Greenhorn

Joined: Mar 08, 2013
Posts: 6
It doesn't seem that's compatible with me since I don't use net-beans or eclipse or others listed. I'm using crimson editor. If you could please just let me know where my mistake lied at least, that would be much appreciated.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

A warm welcome to the ranch Glen. Always use code tags to post code:



That's much better. Ain't it?

First things first. Are you new to Java?


~ Mansukh
Glen Richard
Greenhorn

Joined: Mar 08, 2013
Posts: 6
Ah yes much much better. And how do the code tags work? I used the code button and filled in my code where it had "java" written.

Thanks for the welcome!

And yes I am new to Java and programming in general.

I've spent about 6 weeks learning and working with it, but seem to be missing some of the more basic logic.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Hmm. Well basics are the most essential part for learning any art, science, sport. I would advise you to start studying from this book. Devote some part of your time daily to understanding the concepts. Then if you have doubts, post them here. We are there for you. But no spoon-feeding. If we directly provide the answers to your queries, you won't be able to appreciate much of it.

Now the answer to your post:
It is a simple case of identifier mismatch. There is no mexicoPopFin in your code. So how will you use it. You ought to declare a variable before you can use it. Right? Same is the case with usPop etc..
Glen Richard
Greenhorn

Joined: Mar 08, 2013
Posts: 6
Well I am actually currently studying java in and introduction to java course at university.

So would I declare it the same as my other variables?

I've now run into the error of the variable's already being defined.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Right: By starting the lines 18, 19 and 23 with "double" you're effectively re-declaring variables that have already been delcared in lines 11, 12 and 13. I suspect you merely want to assign to those variables - so remove the word "double" and see what happens.


Ping & DNS - my free Android networking tools app
Glen Richard
Greenhorn

Joined: Mar 08, 2013
Posts: 6
That was it! I can't believe I was overlooking that...thanks!

Now I'm faced with the issue of nothing printing out...

I tried moving the println to the if block but that did not change anything, still no output, but the program runs...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Glen Richard wrote: . . . I can't believe I was overlooking that... . . .
Lots of people make that mistake, so don’t worry about it.

What you are doing is using the != operator on floating‑point numbers. They are not precise (see no 20), so they never become exactly the same. So the loop never finishes. At least not until both populations reach ∞!
Try replacing the != operator with < or <=

And welcome to the Ranch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: error: cannot find symbol, help!
 
Similar Threads
class or interface expected?
Population and Growth Rate Problem
Strange Vector3(double, double, double) symbol not found?
code is complete! but whats wrong here??
error: cannot find symbol, help!