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 need help AGAIN!

Is this how you do this?String firstName = "Austen"; console.printf("firstName can code in Java!", firstName);

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

4 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.

Rob Allessi
Rob Allessi
8,600 Points

Austen Ham glad to see you're getting assistance, but we wanted to reach out regarding the number posts you've created on this topic within such a short spanβ€” it's a bit excessive. We're requesting that you please keep your requests on this specific topic isolated to a singular thread (this thread) and allow time for people to respond. Your other 6 posts on this have been removed. Thanks for understanding.

Sorry ' bout that

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Sloooooooooooooow down. Watch the videos over again. Try things out in your own text editor/Workspaces. Learning to code is hard but it's completely achievable; takes time, patience, and a strong attention to detail. You won't do yourself any favors by rushing from challenge to challenge and then rushing to the community for help on everything.

Take your time, do challenges a few times so you really cement their concepts in your brain. You got this.

Christopher Downie
Christopher Downie
2,546 Points

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