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!

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 Add a Constructor

casey bova
casey bova
Courses Plus Student 1,541 Points

I need help with add a constructor

I need help with challenge task 3 of 3 in add a constructor I am having trouble I would like to understand thise

public class GoKart {
  public String color = "red";

  public GoKart(String color) {
     this.Color = color;

  public String getColor () {
    return = Color;


1 Answer

Mihai Craciun
Mihai Craciun
13,520 Points

the third question asked you to remove the initialization from the field definition so you just have to remove the "red" parameter from String color = "red";

This is because when you will create an object which type is GoKart you will already pass a color parameter so there is no point to declare it in object

The code should be look like this:

class GoKart {
  private String color;

  public GoKart(String color){
    this.color = color;

  public String getColor() {
    return color;