Java Java Objects Harnessing the Power of Objects Add a Constant

Josh Haefner
Josh Haefner
1,110 Points

Java constant code challenge

I keep getting an error stating that the integer max battery is not accessible in the class.. what am i doing wrong??
class GoKart {
  private String color;
  public final int MAX_BARS = 8;

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


1 Answer

You need to declare MAX_BARS variable as static so that we can access it directly with the class name