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 (2014) Getting Started with Android Troubleshooting Java

Adebiyi Dayspring-Adenusi
PLUS
Adebiyi Dayspring-Adenusi
Courses Plus Student 57 Points

String favoriteColor = "black"; what is wrong with the above line of code

Tried running this in the compiler but gave me the "bummer" notification

Color.java
favoriteColor String equals "";
String favoriteColor = "black";

4 Answers

Alexandra Kaplan
Alexandra Kaplan
1,167 Points

I'm guessing from my Swift knowledge, but I think it's supposed to be:

favoriteColor:String="black"

OR

favoriteColor[String]="black"

when you are identifying something as a string you have to use a precursor

Seth Kroger
Seth Kroger
56,413 Points

Your second line is how it should be in Java. Remove the first, because it's not valid Java syntax, and it should be fine.

Also, if it isn't obvious, Swift is not Java.

Adebiyi Dayspring-Adenusi
PLUS
Adebiyi Dayspring-Adenusi
Courses Plus Student 57 Points

thanks guys. Found out that the error was in my lack of spacing between the semicolon and quotation mark

string favouriteColor = "Black"