Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java Strings, Variables, and Formatting

I do not understand

the first challenge in beginning java task 2 I do not understand

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "weston";

2 Answers

Antonio De Rose
Antonio De Rose
20,882 Points

give a try, go through the video over and over, and then try it out, if you make an effort, we can help find out what is missing / lacking

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 10,991 Points

I recommend that you go back and re-watch the video, probably taking notes, since you aren't retaining the information after videos.


The challenge is asking you to use the printf() method to display a formatted text with the value of <Your Name> can code in Java!. So we will use the printf syntax to do that. You should be used to using print statements by now so I won't go over what the syntax for it should look like, instead I will go over the specifics needed to solve this.

Step 1: The print statement!

// Challenge 1
String firstName = "weston";
// Challenge 2
System.out.printf("<Your Name> can code in Java!");

This is the next challenge part below!

Step 3: Replacing <Your Name> with the variable for your name. That's it we are done!

// Challenge 1
String firstName = "weston";
// Challenge 2 & 3
System.out.printf("%s can code in Java!", firstName);

printf uses a tag-based formatting system to display variables or format text. Here we are using the tag %s to designate that we are expecting type of String to be there. We then provide the variable for that tag at the end of the print statement after the comma. Again if this is confusing please re-watch the videos covering PrintF statements and take notes.