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

copied workspace perfectly... didn't work! this is frickin hard!

i just need some tips on how to get it started...

Name.java

2 Answers

John Anselmo
PLUS
John Anselmo
Courses Plus Student 2,281 Points

Dallas,

Don't just copy the workspaces. The code for these challenges is supposed to be specifically for these challenges. I'll walk you through it.

First thing's first, assigning your first name to a variable. What variable would your first name be? That's right, a String.

Task 1/3 code;

String firstName = "YourFirstName";

Task 2/3 wants you to call the printf method on the console and make it write your "<YOUR NAME> can code in java!" Calling printf on console basically means to write console.printf. It literally wants you to write "<YOUR NAME> can code in Java!"

Task 2/3 code:

String firstName = "YourFirstName";
console.printf("<YOUR NAME> can code in Java!");

Task 3/3 wants you to access the firstName variable and print it out instead of "<YOUR NAME>". To do this, you will have to recall the String formatter that you learned in the lessons: %s

Task 3/3 code:

String firstName = "YourFirstName";
console.printf("%s can code in Java!", firstName);

To tell the console what variable you want to print for %s, you place a comma after the closing double-quote, and put the variable, which is, in this case, firstName.

Hope this helped!

Thanks!! That helped a ton... I got it now,