Java Java Objects Meet Objects Add a Getter

Roger sam
Roger sam
566 Points

Add a getter method that exposes the color field.

class GoKart { private String color = "red"; public String getcolor() { return color; } }

GoKart.java
class GoKart {
  private String color = "red";
  public String getcolor() {
    return color;
  }
}
saykin
saykin
9,820 Points

I'm unsure as what you are asking for here? Could you elaborate?

1 Answer

Steven Parker
Steven Parker
202,107 Points

The convention for method naming is "camel case", so it should be "getColor" with a capital "C".