aspose file tools
The moose likes Beginning Java and the fly likes Whats wrong here? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Whats wrong here?" Watch "Whats wrong here?" New topic
Author

Whats wrong here?

Ryan Medrano
Greenhorn

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

GuessGame.java:46: cannot find symbol
symbol : variable p1isRight
location: class GuessGame
p1isRight = true;
^

GuessGame.java:59 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
Bartender

Joined: Aug 16, 2005
Posts: 12950
    
    3

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 7 API documentation
Scala Notes - My blog about Scala
Ryan Medrano
Greenhorn

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
Bartender

Joined: Oct 02, 2003
Posts: 10040
    
    6

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).


Never ascribe to malice that which can be adequately explained by stupidity.
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: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Whats wrong here?
 
Similar Threads
Compile Errors - Head First - GuessGame
Guess game compiling error
Head First Java Ch. 2 Compile error
GuessGame.java:2: cannot resolve symbol
GuessGame Errors From Head First Java