'Why is Eclipse asking to declare strictfp inside enum

I was trying out enum type in Java. When I write the below class,

public class EnumExample {
  public enum Day {
    private String mood;
    MONDAY, TUESDAY, WEDNESDAY;
    Day(String mood) {

    }
    Day() {

    }
  }
 }

Compiler says: Syntax error on token String, strictfp expected.
I do know what's strictfp but would it come here?



Solution 1:[1]

You have maybe forgotten to add semicolon after last enum constant.

public enum Element {
    FIRE,
    WATER,
    AIR,
    EARTH,  // <-- here is the problem

    private String message = "Wake up, Neo";
}

Solution 2:[2]

The enum constants must be first in the enum definition, above the private variable.

Java requires that the constants be defined first, prior to any fields or methods.

Try:

public enum Day {
    MONDAY, TUESDAY, WEDNESDAY;
    private String mood;
    Day(String mood) {

    }
    Day() {

    }
  }

Solution 3:[3]

You can't define instance variable before enum elements/attributes.

public enum Day {
   
    MONDAY("sad"), TUESDAY("good"), WEDNESDAY("fresh");
    private String mood;
    Day(String mood) {
    this.mood = mood;
 }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Firzen
Solution 2 rgettman
Solution 3 Anil Nivargi