Java Java Objects Meet Objects Add a Constructor

Md Meer
Md Meer
469 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

bot .net
bot .net
10,247 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.