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 trialJames Stride
Courses Plus Student 621 Pointsnot-static variable MAX_PEZ cannot be referenced from a static context PezDispenser.MAX_PEZ);
Cant figure out why Im getting this error since its exactly like Craigs code.
Example.java:7:error: non-static variable MAX_PEZ cannot be referenced from a static context
PezDispenser.MAX_PEZ);
^
2 Answers
James Stride
Courses Plus Student 621 PointsThank you so much Madhuri ! I laughed about it once I saw that mistake.
Uris Nicolas
1,906 PointsThank you very much !!
Madhuri Charugundla
2,383 PointsMadhuri Charugundla
2,383 PointsYou forgot to mention the keyword static before the constant variable MAX_PEZ. If you want the constant to be accessed from the class instead of object scope, then you have to mention static keyword. public static final int MAX_PEZ = 12;