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 Privacy and Methods

I'm not sure how to answer this question

where do i put the public?

GoKart.java
public class GoKart {
  public String mColor = "red";
  public String getColor() {
  return Color};
}

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Emily,

1) You'll want to return mColor, because that's the name of the String variable you're using to store the GoKart's color.

2) You'll want to move the closing curling brace that you have inside the return statement to some point after the return statement: the semi-colon is part of the return statement and ends that line, and you want to make sure the closing brace isn't used until after you're done with the body of your getColor() method.

public class GoKart {
  public String mColor = "red";
  public String getColor() {
    return mColor;
  }
}

Hope this helps!

Thank you so much! I was really stuck there for a while, but you really cleared it up! :)