Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Michael Brent
883 PointsHaving trouble with variable.
I don't know what im doing wrong. I declared the variable and assigned the color red to the string but it keeps getting a complier error.
5 Answers

Michael Brent
883 Pointsvar favoriteColor = "red";

Jason Anello
Courses Plus Student 94,592 PointsThat would be fine with javascript.
The type of the variable needs to be declared in java.
Try replacing var
with the data type of that variable.

Michael Brent
883 Points<p> JavaTester.java:21: cannot find symbol symbol : class var location: class JavaTester var favoriteColor = "red";
</p>

Jason Anello
Courses Plus Student 94,592 PointsThe variable has a String data type. Did you replace var
with String
?

Michael Brent
883 Points<p> JavaTester.java:19: cannot find symbol symbol : class string location: class JavaTester string favoriteColor ="red"; ^ 1 error
<\p>

Jason Anello
Courses Plus Student 94,592 PointsShould be a capital S

Michael Brent
883 PointsThank you your awesome!

Jason Anello
Courses Plus Student 94,592 PointsYou're welcome.
Jason Anello
Courses Plus Student 94,592 PointsJason Anello
Courses Plus Student 94,592 PointsWhat did you put down so far?