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 trialhabib kazemi
2,041 Pointsproblem with code chalenge
i type string favorite Color = "blue"; but it doesn't work.
4 Answers
Gunjeet Hattar
14,483 PointsI did the same and it works.
Maybe some typo error.
Ben Singer
8,621 Pointsdoesn't the variable name need to be favoriteColor?
Gunjeet Hattar
14,483 PointsIf 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
2,041 Pointsi 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?
Gunjeet Hattar
14,483 PointsI made a mistake it should be favoriteColor instead of favouriteColor
Should work now
MUZ140918 Frank Thabo
3,839 Pointsspelling matters , turns out i was typing favoUrite... the U factor was messing up everything
habib kazemi
2,041 Pointshabib kazemi
2,041 PointsYes it works now ,thanks but why I should use capital for color ? (That was my mistake)
Gunjeet Hattar
14,483 PointsGunjeet Hattar
14,483 PointsIt 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