Java Java Objects Harnessing the Power of Objects Add a Constant

I got a weird error message but cant figure out what I did wrong here.

Bummer: java.lang.IllegalArgumentException: ParseException: com.github.javaparser.ParseException: Encountered " "=" "= "" at line 4, column 27. Was expecting one of: <IDENTIFIER> ... <IDENTIFIER> ... <IDENTIFIER> ... <IDENTIFIER> ... <IDENTIFIER> ... <IDENTIFIER> ... <IDENTIFIER> ... (Look around Inspector.java line 73)

The above is the error I got for my code:

class GoKart { private String color;

public static final int = MAX_BARS=8;

public GoKart(String color) { this.color = color; }

public String getColor() { return color; }

}

Not entirely sure what I did wrong

GoKart.java
class GoKart {
  private String color;

  public static final int = MAX_BARS=8;

  public GoKart(String color) {
    this.color = color;
  }

  public String getColor() {
    return color;
  }

}

2 Answers

saykin
saykin
9,820 Points

Your error is in this line of code

public static final int = MAX_BARS=8;

You have two equal characters, as it says in the error.

The syntax for setting variables in Java is <type> <name> = <value>

I could get why the error message is very confusing, if it doesn't make sense, check which line the error/exception happened. In this case, line 4.

Oh darn! :D

Well spotted, thank you. I was so confused too,