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

Errors on my work space with folder Tree Story. i feel like the compiler has got issues. please help

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!
    */
}

String name = console.readLine("Enter your name: "); String adjective = console.readLine("Enter an adjective: "); String noun = console.readLine("Enter a noun"); String adverb = console.readLine("Enter an adjective: "); String verb = console.readLine("Enter an adverd ending in-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); }

I keep getting errors from the compiler

  1.                                                  ^                                                                      
    

    TreeStory.java:21: error: <identifier> expected
    console.printf("they are always %s %s. \n", adverb, verb);
    ^
    2.TreeStory.java:19: error: illegal start of type
    console.printf("your TreeStory:\n---------------\n");

  2.              ^                                                                                                         
    

    TreeStory.java:21: error: <identifier> expected
    treehouse:~/workspace$ javac TreeStory.java
    TreeStory.java:19: error: <identifier> expected
    console.printf("your TreeStory:\n---------------\n");

I really suspect the compiler is having issues. guys i need help please.

1 Answer

chidera, i just tried this in a Treehouse javascript workspace and it worked fine:

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!
       */
       String name = console.readLine("Enter your name:  ");
       String adjective = console.readLine("Enter an adjective:  ");
       console.printf("%s is very %s\n", name, adjective); 
   }   
} 

Here's the output of a run:

treehouse:~/workspace/com/teamtreehouse$ javac TreeStory.java && java TreeStory
Enter you name: chidera
Enter an adjective: funny
chidera is very funny

Hi @jcorum thank you! I found my mistake :) your awesome!