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

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