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

Ben Schaal
PLUS
Ben Schaal
Courses Plus Student 408 Points

Add a public method, or getter, that can be used to get the color of the go kart. Why am i getting an error?

I do not understand why i keep getting a syntax error. I've looked at other forum posts and have written out the code exactly like the have and still having issues.

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

  public GoKart(String color){
    mColor = color;
  }
  public String getColor(){
    return mColor;
  }
}

3 Answers

Ben Schaal
PLUS
Ben Schaal
Courses Plus Student 408 Points

Well the answer o had was the one for the next challenge. Mir kept giving me an error saying I needed another string.

Ben Schaal
PLUS
Ben Schaal
Courses Plus Student 408 Points

Ended up figuring out my mistake after re-watching the video. thanks for the response though.

Ben Schaal
PLUS
Ben Schaal
Courses Plus Student 408 Points

I had the answer for the next challenge. Sorry about the delay in response. I thought it sent before but I guess it didn't.