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 Getting Started with Java Strings, Variables, and Formatting

Can someone hepl me, i dont know why the code is wrong?

I do exactly the challenge said, but it's not run

Name.java
        Console console = System.console();
String firstName = "Hung";
console.printf = ("Hung can code in Java!");
Nick Oman
Nick Oman
5,041 Points

Hi Hung,

You do not need to create a new console because java.io.console has already been imported. If you remove that line I believe the code will run.

A good place to run down errors is in the editor window. You can access it by clicking the editor<> button. I copied your code and received the following error when running:

variable console is already defined in method run()

// The code below is for Challenge Task 1 of 3.
String firstName = "Nick";

// The code below is for Challenge Task 2 of 3.
console.printf("Nick can code in Java!");

// The code below is for Challenge Task 3 of 3.
console.printf("%s can code in Java!", firstName);

1 Answer

A Y
A Y
1,761 Points

ag,

Console console = System.console(); //This is ok String firstName = "Hung"; //This is ok console.printf = ("Hung can code in Java!"); //This is a bug It supposed to be ((console.printf("Hung can code in Java!");)))

Regards, Amir