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 (Retired) Meet Objects Creating Classes

Now let's temporarily add a public field that we will use to store the color of the GoKart. Let's make it the set to the

Why it telling me that I went overboard, What is wrong ?

GoKart.java
public class GoKart {
  public String mCharaterName = "GoKart"; 
  String mColor = "red";
}

2 Answers

Isaiah Marin
Isaiah Marin
11,971 Points

Hey ahmed, I've noticed that you haven't set your String class member 'mColor' to public.

I changed to public but still telling me that I should not go overboard ?!!

Isaiah Marin
Isaiah Marin
11,971 Points

Hey, So I just did the challenge myself and it only asks for you to make the public String mColor = "red". Since you have added an extra line of code it states that you are going overboard.

Thus remove the following line:

public String mCharaterName = "GoKart";

Now you should only have the following:

public class GoKart {

  public String mColor = "red";

}

Hope this helps.

Charles Franklin
Charles Franklin
17,535 Points

I'm so confused after having completed CSS. In CSS you declare an object and assign attributes to it. Admittedly you can go very deep with selectors and objects but at the root is a single block of code which says this is how I want this styled.

Here in Java it seems were moving away from that. We have the class GoKart. Ok, but then why don't I just assign it a color? Why do we have to create a new variable and assign that a color. Sorry, stepping off soapbox...

chip