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

Java Java Objects Meet Objects Create a class and field

Rabab El-Zohbi
Rabab El-Zohbi
1,859 Points

Great! Now add a field named color of type String that will be used to store the color of the GoKart. Set the value to "

Great! Now add a field named color of type String that will be used to store the color of the GoKart. Set the value to "red"

GoKart.java
class GoKart {
  string namedcolor="red";
}

4 Answers

First off, you need to capitalize the S in string. Java is picky about capitalization :)

Next, you need to set the name to exactly what the challenge asked you to name it. Instead of naming the variable namedcolor, you should name it just color.

Finally, you need to set the value of the variable to what the challenge to what it's excepting it to be. You should set tthe value to "red" and not just an empty string.

I know, I know, code challenges and Java are both picky, but you just have to get used to it. :smile:

I hope you understand. ~Alex

The answer is

class GoKart { String color="red"; }

public class GoKart { String color = "red";

}

Hi there,

Others have already given their point but I'll also like to add mine as currently taking the course.

Answer is:

class GoKart { String color = "red"; }