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 trialMUZ140202 Oniel Chamburuka
5,250 Pointshow 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
Treehouse TeacherFirst 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!
MUZ140202 Oniel Chamburuka
5,250 PointsMUZ140202 Oniel Chamburuka
5,250 Pointsthanks Craig,but there was any error,i typed string firstName="Oniel"; the error was that it could not find symbol
Craig Dennis
Treehouse TeacherCraig Dennis
Treehouse TeacherCase matters! String has a capital S.
Hope it helps!
MUZ140202 Oniel Chamburuka
5,250 PointsMUZ140202 Oniel Chamburuka
5,250 Pointsthanks 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
Treehouse TeacherCraig Dennis
Treehouse TeacherLook at the instructions carefully. I think it asks for "First name: %s"