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 Helper Methods and Conditionals

Guy Hagan
Guy Hagan
1,985 Points

I keep getting the error message class interface or enum expected

This is 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());
  loadYOrN=console.readLine("Would you like to lad it yes or no?");
    do{
      if (loadYOrN.equals("yes")){
      dispenser.getPezCount=dispenser.getPezCount+1;
      }
    }while (loadYOrN.equals("no"));

  }

    ;


}

} and this is the error message Example.java:22: error: class, interface, or enum expected
}

Thanks all answers appreciated

1 Answer

Seth Kroger
Seth Kroger
56,414 Points

It's the stray semi-colon on it's own near the bottom. Removing it should clear that up.

Guy Hagan
Guy Hagan
1,985 Points

thanks its solved now