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 have confusion with this question.

I would like to just be given an example.

Name.java
String FirstName="Chance";
console.printf("%S is very confused rn")
Mathew Tran
Mathew Tran
Courses Plus Student 10,205 Points

The validator for some of these quizzes are pretty strict.

  • Note the first challenge where it says the variable needs to be "firstName". Note the camel casing.
  • For the second part of the challenge you almost have it, after using %s to in your printf call, you need to map it to a string variable.
console.printf("%s can code",firstName);

Matt.

1 Answer

Steven Mattia
Steven Mattia
1,698 Points

You have it all right but just are not printing out the variable correctly. You do %s as a placeholder for a String that is coming up. In your case you use %s but do not provide the variable that should take that place so it does not know what to replace %s with. How you do this is add a comma after the text and add the variable like this:

String firstName = "Chance";
console.printf("%s is very confused rn", firstName);

Thank you