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

Hi, I already made the first step on Java.

Hi, I already made the first step on Java. but on the challenge task 1 Im stuck in. define a string, and I have no idea how to start. should I start with console etc ?

Name.java
// I have setup a java.io.Console object for you named console

3 Answers

Durim Kryeziu
Durim Kryeziu
14,002 Points

Hi Juan,

First things first, read carefully the question and don't let the comments on the editor section to mislead you (If you don't know yet, everything after // is considered a comment).

So the question is: Define a string variable named firstName that stores your name. Set the value to your name.

Define a string variable means you have to start with String

...variable named firstName... means you have to name that variable firstName, you do this by adding firstName after String, you'll get String firstName

...that stores your name..., you have to follow the above ones by equal sign, one equal sign means to store something on that variable. To store what ? To store the value found on its right side.

...Set the value to your name., the last one which completes the challenge: String firstName = "Juan";

To summarize: You declared a variable named firstName of type String which stores the text Juan on it.

P.S. This one: // I have setup a java.io.Console object for you named console you have to use on the next steps, I would recommend Treehouse staff to get rid of this comment from first step to not mislead the other beginners :)

Hope it helps!

Thank You very much ! this help me a lot !! I was a little confuse about it. Thanks for the help !!

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I would prefer to know what you've tried that's failed so I could better explain what you're not understanding. I would highly suggest you go back and review the video. But this is how we declare and initialize a string in Java:

String firstName = "Juan";

Thank You very much !!

Zygimantas Debesys
Zygimantas Debesys
982 Points

Hello, i write a correct thing but seems like it doesn't complete the challenge. String FirstName = "Zygis";

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Zygimantas Debesys because it isn't correct for the challenge. Keep in mind that you must do exactly as they say. They want the variable to be named firstName... not FirstName. Note the capitalization.

String firstName = "Zygis";