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 not be solved

this question i can not solve it Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!" please help me

Name.java
// I have setup a java.io.Console object for you named console
String firstName = ("sohib");
Console.printf("Hello, my name is sohib");
David Tanton
David Tanton
1,937 Points

Hi Sohib

Bit of a beginner myself but I think I can see the problem.

The first is a syntax error on the console.printf command. you have started the command with a upper case C.

The second is that you are not in fact using the String firstName in your printf statement as you have hard coded your name directly.

try the following:

("hello, my name is %s ", firstName)

not sure of the correct terminologically but the %s is used by the console.printf to ask for a variable which you add after the comma.

1 Answer

First of all, you are printing the wrong message.

Second, you aren't using formatting.

Third, Console has to be all lowercase letters.

Try this:

String name = "Sohib";
console.printf("%s can code in Java!", name);

Any questions? Please ask below :smile:

~Alex