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 Parsing Integers

My workspace never displays, "How old are you ?". I get several errors although I typed everything exactly the same as C

My workspace never displays, "How old are you ?". I get several errors although I typed everything exactly the same as Craig. How can I reset my workspace back to the default before what I recently saved? I may have deleted important code.

10 Answers

Thank you. You are indeed missing a closing bracket.

You should have:

  • a closing bracket for the if block
  • a closing bracket for the main method
  • a closing bracket for the class

You were actually missing 2 previously. My bad, I only saw 1 missing. I edited my previous answer. Just add a closing bracket and you will be fine :)

public class TreeStory {

    public static void main(String[] args) {
        Console console = System.console();
        /*  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!
        */
      // __Name__ is a __adjective__ __noun__.  They are always __adverb__ __verb__.
      String ageAsString = console.readLine("How old are you? ");
      int age = Integer.parseInt(ageAsString);
      if (age < 13) {
        //Insert exit code
        console.printf("Sorry you must be at least 13 to use this program.\n");
        System.exit(0);
      }    // <- closing bracket for the if block
    }      // <- closing bracket for the main method
}          // <- closing bracket for the class

screen shot your code please

I edited my previous post

Hi Monica. You have 2 options:

  • Go to Workspaces on the right of the Treehouse top menu bar up there ^ (next to your points) and delete the workspace from the list. Then re-create a brand new one from the lesson.
  • Post your code here so we can help you find where the error is.

Hope that helps :)

import java.io.Console;

public class TreeStory {

public static void main(String[] args) {
    Console console = System.console();
    /*  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!
    */
  // __Name__ is a __adjective__ __noun__.  They are always __adverb__ __verb__.
  String ageAsString = console.readLine("How old are you? ");
  int age = Integer.parseInt(ageAsString);
  if (age < 13) {
    //Insert exit code
    console.printf("Sorry you must be at least 13 to use this program.\n");
    System.exit(0);
}

}

Same error: Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:22: error: reached end of file while parsing
}
^
1 error

Hi Monica. It looks like you're just missing the closing bracket for your if block:

public static void main(String[] args) {
      Console console = System.console();
      /*  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!
       */
        // __Name__ is a __adjective__ __noun__.  They are always __adverb__ __verb__.

      String ageAsString = console.readLine("How old are you? ");
      int age = Integer.parseInt(ageAsString);
      if (age < 13) {
         //Insert exit code
         console.printf("Sorry you must be at least 13 to use this program.\n");
         System.exit(0);
      }    // <- Add this missing bracket
}

Hope that helps:)

Edit: 2 closing brackets were actually missing

same error: Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:22: error: reached end of file while parsing
}
^
1 error

import java.io.Console;

public class TreeStory {

public static void main(String[] args) {
    Console console = System.console();
    /*  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!
    */
  // __Name__ is a __adjective__ __noun__.  They are always __adverb__ __verb__.
  String ageAsString = console.readLine("How old are you? ");
  int age = Integer.parseInt(ageAsString);
  if (age < 13) {
    //Insert exit code
    console.printf("Sorry you must be at least 13 to use this program.\n");
    System.exit(0);
  }

}

it doesn't show both brackets inside the cmd prompt screen but it is there

Hi. It is not there in the code you pasted above.

i have a screen shot. it is. not sure why it doesn't show

You need 2 closing brackets after

System.exit(0);

One for the if block and one for the main method, as in the code I included in my previous answer.

Are you able to access my forked ws?

Yes, just post the link here. I'll have a look

it worked!!!! thanks

You're welcome! Glad it's sorted :)

Thanks so much for helping me through this! I'm learning tons

No problem. I'm glad you're enjoying this. Happy coding! :)