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 trialAR Ehsan
7,912 PointsChallenge Task 1 of 3 Define a string variable named firstName that stores your name. Set the value to your name
This is my first java program. I need some help.Thanks!
// I have setup a java.io.Console object for you named console
3 Answers
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey Abdullah!
Java has a very specific way for defining variables, it will generally look like this.
Type varName = value;
So in this instance to set a String variable called firstName it would be
String firstName = "Abdullah";
Thanks don't hesitate to let me know if this doesn't help, and I'll try to further clarify.
Steve Hunter
57,712 PointsYou'd need to amend that to:
String firstName = "Abdullah";
Strings need to be bounded by double-quotes. ;-)
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsThank you, fixed that. Must have forgotten it when I had my mind on talking about the context of the variable.
Alice Wu
836 Pointsstring firstName = "Alice";
console.printf("Hello, my name is %s\n", firstName);
AR Ehsan
7,912 PointsHey Alice Wu!
I completed that about 12 days ago! Thanks for trying to help!
Abdullah Ehsan