[Solved] Why do we need fields in Interfaces in java? Where do we use these static final fields?


I actually think of them as “constants” (static final does not directly imply a constant for any Type in Java), say i have a enum like this:

public enum ModeEnum {
   FAIL_FAST, FAIL_RETRY, HUNDRET_MORE_MODES
}

And a Interface like this:

public interface ISample {

    static final ModeEnum DEFAULT_MODE = ModeEnum.FAIL_FAST;

    public void process(ModeEnum mode);

}

I would just see the “constant” to imply which of the Enum-States is considered the (mostly supported) default.

I must also note that i never see those “constants” in daily business interfaces.

solved Why do we need fields in Interfaces in java? Where do we use these static final fields?