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

Timothy Feltner
Timothy Feltner
556 Points

I dont know why my code is wrong

I think my code is right?

Name.java
// I have setup a java.io.Console object for you named console
String firstName="Tim";
console.printf=("Timothy");

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Timothy,

There are a couple things going wrong here.

  • First, the second part of the challenge wants you to print our a very specific sentence, but you are just trying to print out a hard coded string. The challenge states: "Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!" ... See the string it wants?

  • Second, while it won't cause any errors, it is a good idea to get into the habit of proper spacing in your code. This will make it much easier for others (and future you) to read it.

Below is the corrected code up to Task #2 for your reference. Have a look, and I hope it makes sense.

String firstName = "Tim";

console.printf("%s can code in Java!", firstName);

:dizzy: