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

Android Build a Simple Android App (retired 2014) Getting Started with Android Java Variables Explained

Michael Brent
Michael Brent
883 Points

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

What did you put down so far?

5 Answers

Michael Brent
Michael Brent
883 Points

var favoriteColor = "red";

That 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
Michael Brent
883 Points

<p> JavaTester.java:21: cannot find symbol symbol : class var location: class JavaTester var favoriteColor = "red";

</p>

The variable has a String data type. Did you replace var with String ?

Michael Brent
Michael Brent
883 Points

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

<\p>

Should be a capital S

Michael Brent
Michael Brent
883 Points

Thank you your awesome!

You're welcome.