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

Example.java:7: error: cannot find symbol

In the previous question the error is pointing to the period or extension. Example.java:7: error: cannot find symbol
System.out.printf("The dispenser character is %s\n", dispenser.getCharacterName());

symbol: method getCharacterName()
location: variable dispenser of type PezDispenser

can you post all of the code?

4 Answers

Ok it looks like you will need to create a get method in dispenser class- I didn't see one.

Hello Jeremy Thanks for replying fast, here is the code:

public class Example {

public static void main(String[] args) {
    // Your amazing code goes here...
  System.out.println("We are a making a new Pez Dispenser");
  PezDispenser dispenser = new PezDispenser();
  System.out.printf("The dispenser character is %s\n", dispenser.getCharacterName());

}

}

Jeremy, and here is the rest:

public class PezDispenser { private String mCharacterName = "Yoda"; }

Thank you Jeremy! it work. I guess I miss that part in the video because I was typing the code and trying to go faster than Craig. Thanks once again.

Cool, you're welcome :)