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 trialWhitney Barber
9,453 PointsThe error message is calling for me to add a ";" where it does not belong. Please assist.
HERE'S THE ERROR MESSAGE...
treehouse:~/workspace$ javac Example.java
Example.java:20: error: ';' expected
If (dispenser.isEmpty()) {
^
Example.java:23: error: reached end of file while parsing
}
^
2 errors
AND HERE'S MY CODE...
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("Yoda");
System.out.printf("The dispenser character is %s \n",
dispenser.getCharacterName());
if (dispenser.isEmpty()) {
System.out.println("It is currently empty");
}
System.out.println("Loading....");
dispenser.load();
if (!dispenser.isEmpty()) {
System.out.println("It is no longer empty");
}
while (dispenser.dispense()) {
System.out.println("chomp!");
}
If (dispenser.isEmpty()) {
System.out.println("Ate all the PEZ!");
}
}
2 Answers
Jeremy Faith
Courses Plus Student 56,696 PointsAlso, do you have a final bracket } to close your class. This could be why you are getting the error Example.java:23: error: reached end of file while parsing.
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsTry making your very last if statement all lowercase instead of the uppercase i. I believe they are case-sensitive, so this would cause an error to be thrown.
Craig Dennis
Treehouse TeacherNice catch Chris Howell !
Whitney Barber
9,453 PointsThat was a good catch! Thank you as well! I got it working now.
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 Points^ yes that could definitely be the case as well.
Whitney Barber
9,453 PointsWhitney Barber
9,453 PointsYes, thank you.