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 Basics Perfecting the Prototype Reviewing Our Feedback

I keep getting error: class, interface, or enum expected }

I can't get past this error:

console.printf("They are always %s %s.\n", adverb, verb);
^
TreeStory.java:29: error: class, interface, or enum expected
}
^
I hope ive been very clear. Below is the exact code:

import java.io.Console;

public class TreeStory {

public static void main(String[] args) {
    Console console = System.console();

  //__Name is a__ adjective__ __noun. They are always__ adverb__ __verb__.

  int age=12;
  if (age= < 13) {
    //Insert exit code
  console.printf("Sorry you most be atleast 13 to use this program.\n"); 
  System.exit(0);
  }

  String name=console.readLine("Enter you name  ");
  String adjective=console.readLine("Enter a adjective  ");
  String noun=console.readLine("Enter a noun  ");
  String adverb=console.readLine("Enter an adjective  ");
  String verb=console.readLine("Enter a verb ending in -ing ");

  console.printf("Your TreeStory:\n----------\n");
  console.printf("%s is a (n) %s %s. ", name, adjective, noun);
  console.printf("They are always %s %s.\n", adverb, verb);


  }

}

I found the problem, in the "if" statement. The equal sign was in front of the greater than sign, =< When the greater than sign should have been in front of the equal sign, or the equal sign should have been removed.

correct example: if (age<13) if (age<=)

wrong examples: if (age=<) if(age>13)

I hope my mistake helps someone else.

Good job finding the problem. I hadn't realized you had solved it and I was copying parts of the code into my work space to see if I could recreate the issue that you were having.

Don't forget to mark this as answered!