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 trialZachary Martin
3,545 PointsPez, Example. java won't compile. Reached end of file while parsing.
Followed along in the example pez dispenser all the way to the end and I keep getting the error message reached end of file while parsing which is usually fixed by adding a bracket but nothing works.
Zachary Martin
3,545 Pointspublic class PezDispenser { public static final int MAX_PEZ = 12; private String mCaracterName;
public PezDispenser (String characterName){
mCharacterName = characterName;
}
public String getCharacterName() { return mCharacterName; mPezCount = 0;
}
public booean dispense() { boolean wasDispensed = false; if (!isEmpty()) { mPezCount--; wasDispensed = true; } return wasDispensed; }
public boolean isEmpty() { return mPezCount ==0;
public void load() { load(MAX_PEZ); } public void load (int pezAmpount) { int newAmount = mPezCount + pezAmount if (newAmount > MAX_PEZ) { throw new IllegalArgumentException ("Too Many Pez") mPezCount = newAmount; }
2 Answers
Seth Kroger
56,413 PointsYou're missing a curly brace at the end of the file. That error is almost always caused by mistakes in matching curly braces.
Tyler Combs
15,525 PointsTip: You can save a snapshot of your workspace and share the link to it so people can view your complete files in workspace without you having to copy/paste a bunch of code. It should be one of the 3 or so icons in the top right of your workspace. When others are viewing your snapshot they can also edit your code and compile and run the program. (it only saves changes client-side)
Zachary Martin
3,545 PointsZachary Martin
3,545 Pointspublic class Example {