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

How do I define a String named firstName correctly? I am having a difficult time with this particular coding exercise

I'm not sure what I am doing wrong, but I wrote out the String = firstName "" and added my name between the quotes and somehow did the exercise wrong.

Name.java
Console console = System.console();
String firstName = "Moses";

2 Answers

There's no need for the first line of code. You should have this as your code:

String firstName = "Moses";

Hope this helps, ~Alex

Yes it did, Thank you Alex!

Can you give me a "best answer" so this question won't be in the "Unanswered questions" section of the Community?

Thanks, Alex

// I have setup a java.io.Console object for you name Public class Name{ Public static void main(String[]args) { Console console = System.console(); String firstName = "Moses"; console.printf(Name); } } why this program giving errors any idea