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 trialMichael 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,610 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,610 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,610 PointsShould be a capital S
Michael Brent
883 PointsThank you your awesome!
Jason Anello
Courses Plus Student 94,610 PointsYou're welcome.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsWhat did you put down so far?