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 Introduction to Your Tools

how do i define a string variable named firstName that stores my name,what is the code that i should write in the worksp

how do i define a string variable named firstName that stores my name ,what is the code that i should write in the workspace

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

First a data type:

String

Then the name :

firstName

Then to set the variable you do

=

And finally the value surrounded by double quotes

"Craig"

Statements end with a semicolon;

Hope it helps!

thanks Craig,but there was any error,i typed string firstName="Oniel"; the error was that it could not find symbol

Craig Dennis
Craig Dennis
Treehouse Teacher

Case matters! String has a capital S.

Hope it helps!

thanks it worked,but errors are still occurring in the next step which wants me to call the printf function on the console object and make it print out "<My name>code in java,,,,i typed console.printf("My name is %s\n",firstName );

Craig Dennis
Craig Dennis
Treehouse Teacher

Look at the instructions carefully. I think it asks for "First name: %s"