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 trial

Java Java Objects (Retired) Harnessing the Power of Objects Incrementing and Decrementing

Whitney Barber
Whitney Barber
9,453 Points

The 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
PLUS
Jeremy Faith
Courses Plus Student 56,696 Points

Also, 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Try 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.

Whitney Barber
Whitney Barber
9,453 Points

That was a good catch! Thank you as well! I got it working now.