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 trialWilliam Owens
8,668 Points2 errors on line 6 PezDispenser
I can't find the errors on: the line that makes the new PEZ
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 is %s %n",
dispenser.characterName);
}
}
5 Answers
Steve Hunter
57,712 PointsHi William,
I can't see the errors either - what errors are you getting and can you post your code from the PezDispenser class too? I'm wondering if there's a little typo in there, perhaps.
Steve.
William Owens
8,668 PointsThanks Steve, I just realized that the Pez class is in a file spelled PezDispensor.java for unknown reasons.
Steve Hunter
57,712 PointsThat shouldn't make any difference - it didn't in my code, but as long as you got going again, that's great. It might have been a recompile that fixed it; the file name seems less critical. Doesn't matter - as long as you're on your way.
William Owens
8,668 PointsHere's the PEZ. I've been trying to copy and paste the errors but somehow it won't let me.
class PezDispenser {
String characterName = "Yoda";
}
William Owens
8,668 PointsHere's the errors. It finally allowed me to copy and paste.
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Example.java:6: error: cannot find symbol
PezDispenser dispenser = new PezDispenser();
^
symbol: class PezDispenser
location: class Example
Example.java:6: error: cannot find symbol
PezDispenser dispenser = new PezDispenser();
^
symbol: class PezDispenser
location: class Example
2 errors
Steve Hunter
57,712 PointsIs your Pez class in a file called PezDispenser.java
?
Steve Hunter
57,712 PointsI tried it with a different file name - it still worked. Have you saved everything and recompiled your code?
You should have no red dots in the tabs at the top of the Workspace and you'll need to run javac Example.java
every time you've saved a change else it'll not recognise the changes.
Daniel Hunter
4,622 PointsI had the same 2 errors on line 6, I just realised that I misspelled the file name for PezDispenser.java, I corrected it and re-run the program then it worked.
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsIt would also help to know what the errors are and whether they are occurring in the PezDispenser.java file instead of the Example.java file.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsClicked send too early - yes, the source of the errors would interesting too. The message should show us that.
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsI hit send a little early too...
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsI'm always on a tablet in the evening - 23:00 here now - and it has the most sensitive "you touched the screen" reflex so it sends stuff that I've rarely finished typing. I should drag the laptop down from the office but that'd just keep me working until far too late! I don't have my work tools on the tablet so I can just browse and watch some tv with my guitar in hand, chilling. (Radiohead's tonight's musical challenge!)