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 trialLucas Alcoba
1,407 Pointscannot find symbol
i have the code word by word as it is on the video but it keeps giving me this error: example.java:6:error: cannot find symbol
public class Example {
public static void main(String[] args) {
// Your amazing code goes here...
System.out.println("We are making a new Pez dispenser.");
PezDispenser dispenser = new PezDispenser();
System.out.printf("the dispenser character is %s\n",
dispenser.mCharacterName);
}
}
my guess is that it can't find the Pezdispenser class we made
Carlos Federico Puebla Larregle
21,074 PointsI don't know what's in your "PezDispenser.java" file but if you did changed the access modifier of the "mCharacterName" variable to "private" you're going to have to access to it from a "getter" method like this:
public String getCharacterName() {
return mCharacterName;
}
And then you'll have to change in the Example file to actually call that method, so instead of "dispenser.mCharacterName" it would be like this: "dispenser.getCharacterName()" (of course if you named the method "getCharacterName()")
I hope that helps a little bit.
Derek Markman
16,291 PointsDerek Markman
16,291 PointsPost your PezDispenser.java file