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

AR Ehsan
AR Ehsan
7,912 Points

Challenge 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!

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

3 Answers

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey 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.

You'd need to amend that to:

String firstName = "Abdullah";

Strings need to be bounded by double-quotes. ;-)

Alice Wu
Alice Wu
836 Points

string firstName = "Alice";

console.printf("Hello, my name is %s\n", firstName);

AR Ehsan
AR Ehsan
7,912 Points

Hey Alice Wu!

I completed that about 12 days ago! Thanks for trying to help!

Abdullah Ehsan