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 can't even figure out the first lesson.

This happened to me when I was trying to follow along on video as well, and i couldn't figure it out then.

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

2 Answers

Harry James
Harry James
14,780 Points

Hey Brian!

You got the first line correct and were close on the second one!

When we use a placeholder like %s, we need to tell it what to replace that placeholder with as an argument within the method it's used. So, it will look something like this:

console.printf("%s is a placeholder", thisIsWhatItWillBeReplacedWith);

Note that thisIsWhatItWillBeReplacedWith would be a String variable.

Try and reword what I've just written to suit this code challenge!


Hopefully this should explain the challenge for you but if you get stuck along the way or if there's something you don't understand here, let me know and I'll make sure to help out :)

Thanks, Harry!

Thanks, Harry!