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

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