Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

Hi, I am not sure what I have been doing wrong but can't seem to resolve a few errors that keep coming up.

These are the error I am getting: TreeStory.java:23: error: illegal start of statement
}
^
TreeStory.java:23: error: reached end of file while parsing
}
^
2 errors

This is what my sheet looks like:

import java.io.Console;

public class TreeStory {

public static void main(String[] args) {


String ageAsString = console.readLine("How old are you?   ");
  int age = Integer.parseInt(ageAsString);
  int age = 12;
  if(age<13)


    /*  Some terms:
        noun - Person, place or thing
        verb - An action
        adjective - A description used to modify or describe a noun
        Enter your amazing code here
        */

}

2 Answers

You imported import java.io.Console; and used a lowercase console in String ageAsString = console.readLine("How old are you? ");. You could instead declare the value of console earlier in your program or use String ageAsString = System.console().readLine("How old are you? "); or some other way to get user input.

If you want your if statement to last more than one line, you will need { and }, such as

if(age<13) {
}

It also looks like you are trying to declare your age variable twice.

  int age = Integer.parseInt(ageAsString);
  int age = 12;

Thank you1