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 Java Basics Perfecting the Prototype Parsing Integers

Hi, I am receiving a string cannot be converted to boolean message

[Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:16: error: incompatible types: String cannot be converted to boolean
String ageAsString = console.readline("How old are you? ");
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error]

Not sure how I am getting the above error. My code is as follows:

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
                    adverb - an adjective that describes a verb

        Enter your amazing code here!
    */
        //*Name* is a *noun*. *Name* is *adjective* at it. They *verb* *adverb*.
        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);
        }

Thanks in advance

1 Answer

Tsenko Aleksiev
Tsenko Aleksiev
3,818 Points

Have you double checked your camel casing? read L ine ;)