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

my current script is console.printf("firstName."). I am currently getting an error stating I need to create a string var

Would i have to delete the first line of code and replace it with something? Please help.

Name.java
// I have setup a java.io.Console object for you named console
console.printf("firstName.");
Abu Muhariba
Abu Muhariba
1,140 Points

I assume this is for the second part of the exercise? You need to remove the quotation marks and the period.

In the first step you should have created a variable to store your name. i.e. String firstName = "Willis";

Therefore in the second step you should print the value stored in your string variable and then the remaining sentence "can code in Java!" i.e. console.printf(firstName + " can code in Java!"); [do not forget the space before the 'can' otherwise the value stored in firstName will be added right before the word can i.e. Williscan code in Java!]

1 Answer

David Evans
David Evans
10,490 Points

Which step of the challenge are you having problems on??

The first step asks you to "Define a string variable named firstName that stores your name. Set the value to your name."

They want you to do that under the commented line of code there.

The console.printf is the second step, and then you change it again in the third step.