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

Rhiannon Sadler
Rhiannon Sadler
351 Points

Could anyone help me with this task?

Im not sure where to go on this one. i know it may seem simple but i have been trying and im confused.

Name.java
// I have setup a java.io.Console object for you named console
console.printf("Rhiannon Sadler");
String firstName = "Rhiannon Sadler";
Rhiannon Sadler
Rhiannon Sadler
351 Points

Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!" thats what i have to do

1 Answer

Christopher Augg
Christopher Augg
21,223 Points

Rhiannon,

No problem. Lets look at these steps one by one.

The first task just wants you to set up a variable to hold your first name.

String firstName = "Rhiannon Sadler";

Good job!

The second task wants you to call the printf method on the console object with a String that says, "Rhiannon Sadler can code in Java!"

I can see how it is confusing because it looks like the instructions are saying to place <YOUR NAME> variable. However, it really just means to write our the whole string starting with your name.

console.printf("Rhiannon Sadler can code in Java!");

The last task is where we want to insert the variable firstName into printf. Do you recall in the video how to use %s within printf?

Hint: console.printf("%s yada yada", VARIABLE)