
James Stride
Pro 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
Pro 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;