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.

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.