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

i DONT UNDER STAND WHAT I AM DOING WRONG

wHAT IS WRONG IN THE CODE

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

2 Answers

andren
andren
28,558 Points

When you use printf to place a variable into a String you need to place a placeholder character in your String in the spot where you want to place said variable. The placeholder for String values is %s so for this task the string has to look like this:

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

The %s will be replaced by the contents of the firstName variable by the printf method when it prints the String.

Also I think your caps-lock key might be on by accident. Based on the capitalization of your title and post.

Christopher Downie
Christopher Downie
2,546 Points

This task actually requires you to use the %s to insert you name in the program. so your code should actually look like console.printf("%s can code in java", firstName);