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 Using your New Tools Coding the Prototype

Nicolas Fernandez
Nicolas Fernandez
159 Points

illegal start epression

Hi, I had been just copying the input, though I had a different outcome.

TreeStory.java:19: error: illegal start of expression
console.printf("Your TreeStory:\n---------------\n");
^
TreeStory.java:19: error: ';' expected
console.printf("Your TreeStory:\n---------------\n");
^
TreeStory.java:21: error: ')' expected
console.printf(They are always %s %s. \n", adverb, verb);
^
TreeStory.java:21: error: illegal character: '\'
console.printf(They are always %s %s. \n", adverb, verb);
^
TreeStory.java:21: error: not a statement
console.printf(They are always %s %s. \n", adverb, verb);
^

3 Answers

Yep - as I suspected, the line before isn't closed correctly; you have corrected the other issue, though. Change:

String verb = console.readLine("Enter a verb ending with -ing:

to:

String verb = console.readLine("Enter a verb ending with -ing: ");

That closes the string, the closing parenthesis of the readLine method and the line with a semicolon.

Steve.

No problem! :+1: :smile:

Hi Nicolas,

Can you post your code, please?

You may be missing an ending semi-colon on line 18 (the code before line 19, anyway!) - but there's some other issues in there too.

Steve.

Nicolas Fernandez
Nicolas Fernandez
159 Points
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 alwyas __adverb__ __verb__.
      String name = console.readLine("Enter a name:  ");
      String adjective = console.readLine("Enter an adjective:  ");
      String noun = console.readLine("Enter a noun:  ");
      String adverb = console.readLine("Enter an adverb:  ");
      String verb = console.readLine("Enter a verb ending with -ing: 

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

    }

}

[MOD - edited code block - sh]

This line:

console.printf(They are always %s %s. \n", adverb, verb);

Wants an opening inverted comma before They:

console.printf("They are always %s %s. \n", adverb, verb);
               ^
Nicolas Fernandez
Nicolas Fernandez
159 Points

I dont see the difference here......

Your original error had this:

TreeStory.java:21: error: ')' expected
console.printf(They are always %s %s. \n", adverb, verb);
^
TreeStory.java:21: error: illegal character: '\'
console.printf(They are always %s %s. \n", adverb, verb);
^
TreeStory.java:21: error: not a statement
console.printf(They are always %s %s. \n", adverb, verb);
               ^
               No "

You were missing the opening " before They. You corrected that since so your code is up to date; have you recompiled the code to take that change into account?

See what I mean?

Steve.

I've added a ^ in the error code to highlight the difference. You've fixed that now, which is great.

So, you just need to change the second issue, below, then save the file and recompile with javac etc, and you'll be fine!

If not, post back and I'll fix whatever comes next! :smile:

Steve.