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

define string of first name

define a string

// I have setup a java.io.Console object for you named console 
string first name = "Varun";

2 Answers

Michael Hess
Michael Hess
24,512 Points

Hello Varun,

First of all string should be capitalized


Secondly try:

String firstName

Using separate names is like giving the variable two names -- which will cause an error. Try using camel case for example: firstName. Camel case means to capitalize the first letter of the second word and leaving out whitespace between words. For example firstName, lastName, middleName, fullName -- notice how the first letter of the second word is capitlized and there is no space in between words. The first letter of the first word is lowercase.

The end result is:

String firstName = "Varun";

Hope this helps!

There are a few things missing here, and I really recommend rewatching the video from about 3:10, as if you are confused about this you are likely to have huge difficulty down the line.

Firstly, Craig hasn't exolained why yet, but note that when he defines a variable, he uses 'String' with an upper case S. This is super important, and Craig will get into why later.

In addition, it's important to know that variable names can't have spaces in them. In the video, Craig talks about the concept of camelCase.

Re watch the video looking out for these and you should be able to easily complete this challenge!