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

victor ghosh
victor ghosh
724 Points

What the **** is the answer? I have tried, cant get it, and the help thing is not understandable!!

i

Name.java
// I have setup a java.io.Console object for you named console
String firstName =  ("victor");
printf ("%s can code in Java", firstName);

1 Answer

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Victor,

There are two issues causing your code to fail the challenge.

  1. To create a string variable, you only need the string literal in quotes. Remove the parenthesis so that it is
String firstName = "victor";
  1. printf is available via System.out so you'll need to prefix the method as such.
System.out.printf("%s can code in Java", firstName);

With these changes the code will compile succesfully and you should pass the challenege.

I hope this helps.

andren
andren
28,558 Points

While the code will indeed compile successfully it won't actually pass the challenge. The code checker for this challenge is quite picky, it does not accept printf statements that have a space between the method and the parenthesis. So you actually have to remove it like this:

String firstName =  "victor";
System.out.printf("%s can code in Java", firstName);

In order to pass the challenge.

Justin Horner
Justin Horner
Treehouse Guest Teacher

Thanks andren, I've fixed the typo in my answer.