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

Console.printf ("Esraa can code in java!"); whats wrong with my code they say there is syntax error

please answer me

Name.java
// I have setup a java.io.Console object for you named console
String firstName="Esraa";
Console.printf ("Esraa can code in java!");

2 Answers

Philip Schultz
Philip Schultz
11,437 Points

Hello, It is asking you to use string formaters.

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

See how you can replace the %s format with a string variable. Let me know if you have any questions.

Hi there,

At this stage, you are hard-coding your name into the output string. The reason your code is failing is because you have capitalised Console. The object is called console with a lowercase 'c'. Change that, and your code passes task 2.

The next task (3 of 3) will use placeholders, as Philip has suggested.

Steve.