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 trial

Java Java Objects Harnessing the Power of Objects Abstraction at Play

Andrei Musat
Andrei Musat
738 Points

Error: cannot find symbol symbol: class PezDispenser PezDispenser pd = new PezDispenser("Yoda");

In my code below I am getting this error:

Error: cannot find symbol
symbol:   class PezDispenser 
PezDispenser pd = new PezDispenser("Yoda"); 

I followed all the links in the questions section and still didn't fix this problem.

I don't know what more to do, I also followed this link ( https://github.com/albertlatacz/java-repl/issues/100 ), still couldn't fix this problem. Can someone help me please ? (obs) once or twice it worked and I didn't get this problem, now here it is again.

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 boolean isEmpty(){  
    return PezCount == 0;
  }
  public String getCharacterName (){
    return characterName;

  }
}

2 Answers

In your isEmpty() method, write

return pezCount == 0;

With a lower case p. Java is case sensitive and for the compiler, pezCount and PezCount are two different variables.

Zak Manz
Zak Manz
1,390 Points

Also line 3 should be: private final String characterName;