Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTravis G
8,384 PointsHaving trouble finding my error. Java Objects
Hello Everybody,
I'm taking a class in: Java Objects > Harnessing the Power of Objects > Filling the Dispenser > at 2:50.
When I launch my code into the console I get error: cannont find symbol
pezCount = MAX_PEZ;
^
I can’t figure out what is wrong here is my code.
Example.java ```public class Example {
public static void main(String[] args) { // Your amazing code goes here... System.out.println("We are making a new PEZ Dispenser"); System.out.printf("FUN FACT: There are %d PEZ allowed in every dispenser %n", PezDispenser.MAX_PEZ); PezDispenser dispenser = new PezDispenser("Yoda"); System.out.printf("The dispenser is %s %n", dispenser.getCharacterName() ); System.out.println("Filling the dispenser with delicious PEZ..."); dispenser.fill(); }
}
PezDispenser.java
class PezDispenser {
public static final int MAX_PEZ = 12;
final private String characterName;
private int PezCount;
public PezDispenser(String characterName){ this.characterName = characterName; PezCount = 0; }
public void fill() { pezCount = MAX_PEZ; }
public String getCharacterName() { return characterName; }
}```
I'm sure it's something simple that I'm missing but I can't seem to find it. Thanks
1 Answer
andren
28,558 PointsCannot find symbol usually means that you have a typo somewhere in the line Java points you at. In this case you seem to have forgotten to capitalize the P in PezCount
. As far as Java is concerned pezCount
and PezCount
are completely different words, even though they look quite similar to a human.
Travis G
8,384 PointsTravis G
8,384 PointsYes, that was it. I don't know how I missed that thanks.