Java Java Objects Meet Objects Add a Constructor

Md Meer
Md Meer
967 Points

Can anyone tell me what I am doing wrong here? Thanks.

class GoKart { private String color = "red";

public GoKart(String color){ return this.color; } public String getColor() { return color; } }

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

  public GoKart(String color){
   return this.color;
  }
  public String getColor() {
    return color;
  }
}

1 Answer

status 401
status 401
14,329 Points

You have few mistakes 1.u need to intialize the constructor with the color variable. 2.u need to get rid of the "red" value after u intialize.