Vague error on enums at runtime

Note: this is Processing 3.3.6

I’ve just started a project, and part of it requires enums. I’ve done my research and found that in order to have enums, they need to be in a seperate .java file. I’ve done that, but at runtime, I get the error Syntax error on token "{", @ expected after this token on line one. I tried humoring it, and adding a single @, but it only continued throwing similar errors. From what I can tell, mind you it has been sometime since I’ve worked with enums, the syntax is perfectly fine. It may also be of not that the code below is the only code contained in its file. So, what’s causing the error?

public enum TileType{
  PLAINS({100,255,125}, true),
  FOREST({15,150,25}, true),
  MOUNTAIN({120, 110, 25}, false),
  CAVE({50, 40, 25}, true),
  DESERT({170, 175, 75}, true),
  VILLAGE({95, 60, 0}, true),
  OCEAN({35, 45, 180}, false),
  RIVER({35, 125, 180}, true);
  
  private int[] tileColor;
  private boolean isPassable;
  
  private TileType(int[] tileColor, boolean isPassable){
    this.tileColor = tileColor;
    this.isPassable = isPassable;
  }
  
  public int[] getTileColor(){
    return tileColor;
  }
  
  public boolean getIsPassable(){
    return isPassable;
  }
  
}
2 Likes

I’m not familiar with enums in any way, but it might have something to do with the arrays in the constructors in the enum. Try adding the new keyword.

enum TileType{
  PLAINS(new int[] {100,255,125}, true),
  // etc.
2 Likes

@colouredmirrorball
Wow, this was it! Real helpful error message there :roll_eyes:. Thank you!