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

What is the problem with this code. It will not compile and gives errors but I feel that I have copied the example given

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 your adjective:  ");
        console.printf=("%s is very %s", name, adjective);
    }

3 Answers

Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:15: error: ')' expected
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);
^ TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: ';' expected
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

You have an = sign after printf

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 your adjective:  ");
        console.printf=("%s is very %s", name, adjective); // Remove = after printf
    }
}

Thanks for your help!