This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Whats wrong here? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Whats wrong here?" Watch "Whats wrong here?" New topic

Whats wrong here?

Ryan Medrano

Joined: Apr 29, 2007
Posts: 11
Hi its me again... i've ran into a little problem. Im making this java app called "GuessGame" its basically a game with 3 players and having them guess a number between 0-9. I've wirten all the source code so far. But when i goto compile it into a class it reads cannot find symbol
symbol : variable p1isRight
location: class GuessGame
p1isRight = true;
^ cannotfind symbol
symbol : variable p1isRight
location: class GuessGame
System.out.println("Player one got it right? " + p1isRight);

whats wrong with player 1? it doesn't have any problems with p2 or p3??? this is what the begging half of my app code looks like

public class GuessGame {
Player p1; // Guess Game has three instance variables for the three Player objects.
Player p2;
Player p3;

public void startGame() {
p1 = new Player(); // Create three Player objects and assign them to the three Player instance variables.
p2 = new Player();
p3 = new Player();

int guessp1 = 0; // Delclare three variables to hold the three guessess the Players make.
int guessp2 = 0;
int guessp3 = 0;

boolean plisRight = false; // Declare three varables to hold a true of false based on the players answer
boolean p2isRight = false;
boolean p3isRight = false;

thats about half... the "declaring" part... well it would be sooo nice if someone could give me hand...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15041

Look at this part of your code:

The name of the first variable is: p, lower case letter L, "isRight". Notice, it's lower case letter L, not the digit 1.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ryan Medrano

Joined: Apr 29, 2007
Posts: 11
WOW!!! Dang man... good eyes!!! thanks alot!!! and bless your soul!!! how did i get l and 1 mixed up? it must be my younger brother distracting me....anyways thanks alot man... i love java~!!!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11923

Any time i get a "cannot find symbol" error, the first thing i do is look for a typo. use a cut'n'paste from the error message, and search for that in the source code. If you only find the line the compiler is complaining about, you have a typo somewhere.

Then i start looking at the scope of the variable to make sure it's still legal where i want to use it (and it probably isn't, if the compiler is complaining).

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joe Wolfe
Ranch Hand

Joined: Apr 25, 2007
Posts: 87
That error message almost always means something is misspelled.

also in some fonts the lower case L and 1 are identical. MIght use diff font if that helps.

If not now then never.
I agree. Here's the link:
subject: Whats wrong here?
It's not a secret anymore!