Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whats wrong here?

 
Ryan Medrano
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ryan Medrano
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12086
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Joe Wolfe
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic