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

habib kazemi
habib kazemi
2,041 Points

problem with code chalenge

i type string favorite Color = "blue"; but it doesn't work.

4 Answers

I did the same and it works.

Imgur

Maybe some typo error.

habib kazemi
habib kazemi
2,041 Points

Yes it works now ,thanks but why I should use capital for color ? (That was my mistake)

It is not compulsory to use capital C for color. But this is what is known as camel casing and usually applied for variable and method names. So the first letter of every second word is a capital letter for e.g. String hello*World , int numberOfP*osts = 20;

In the case of treehouse however you will find an error if make the c of color small because I believe its been set to recognize color as capital C and if you dont if throws a bummer! When doing actual programming its completely up to you how you want to name it

doesn't the variable name need to be favoriteColor?

If you type favourite (space) Color, java will think you are referring to two differernt variable names i.e. favourite and Color

Also in java String starts with a capital letter. So it's incorrect to say string

Java, thus Android is a strictly typed language, meaning you should be very careful with the case of the letter. For e.g. String and string are two different things in java

This is the correct answer

String favouriteColor = "blue";

Hope this helps

habib kazemi
habib kazemi
2,041 Points

i copy your code but it still don't work and show me: Bummer! Identify the different parts of the code. Which part defines the type of the variable? Which part is the name of the variable? What order should they be in? Is 'equals' the correct operator for assigning a value to a variable?

I made a mistake it should be favoriteColor instead of favouriteColor

Should work now

spelling matters , turns out i was typing favoUrite... the U factor was messing up everything