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 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,885 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 11,077 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.