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

My response to Challenge question : string firstName ="Amal"; Shows compiler error

Challenge Task 1 of 3: Define a string variable that specifies your name. I do not understand the meaning of compiler error?? What should be the accurate input?

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

3 Answers

Julian Garcia
Julian Garcia
18,380 Points

The uppercase first letter in string maybe? This works for me:

String firstName="Amal";

Hope this help.

John Marley
John Marley
8,740 Points

A compiler error is returned when there is a mistake in your code and it can not be run. "A compiler is a computer program... that transforms source code written in a programming language (the source language) into another computer language (the target language)... The most common reason for converting source code is to create an executable program. (Wikipedia)

The most likely reason for a compiler error at this stage is your syntax (which is absolutely fine) and your code should be expressed like this.

String myName = "Jeff";

//String is the data type (String being a word or several words, Char being character etc.)
/* myName is the variable name and is usually written with a lower case first letter 
and capital for the next word */
//Jeff is the value stored (My name is Jeff)