Why can’t I create an enum in an inner class in Java?

enum types that are defined as nested types are always implicitly static (see JLS §8.9. Enums)

You can’t have a static nested type inside a non-static one (a.k.a an “inner class”, see JLS §8.1.3. Inner Classes and Enclosing Instances).

Therefore you can’t have an enum inner type inside a non-static nested type.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)