Java Java Objects Meet Objects Add a Constructor

Yakir Haviv
PRO
Yakir Haviv
Pro Student 1,060 Points

Finally, since the color is being set in the constructor now, remove the initialization from the field definition. Just

class GoKart { private String color = "red";

public String getColor() { return color; } public color(String color) { this.color = "red"; }

}

GoKart.java
class GoKart {
private String color = "red";

  public String getColor() {
    return color;
  }
   public color(String color)
   {
     this.color = "red";
   }

   }