Enum static import
Posted: Tue Aug 27, 2013 3:31 am
Hi everybody,
Having an enum declared within a class:
Would it be correct importing the Days's fields MONDAY and SUNDAY in a static way?
import static EnumKindOfThing.Days.*;
i know that the enum fields (MONDAY and SUNDAY in this case) are implicitily final and static. Therefore it should work should not it?
PS: At the moment I cannot test it myself as I cannot use my laptop.
I am sure that import static EnumKindOfThing.*; would work as the enum is seen as a static nested class. However I would like to know the exact above posted example.
Thanks in advance.
Having an enum declared within a class:
Code: Select all
public class EnumKindOfThing{
public enum Days{MONDAY,SUNDAY};
}
import static EnumKindOfThing.Days.*;
i know that the enum fields (MONDAY and SUNDAY in this case) are implicitily final and static. Therefore it should work should not it?
PS: At the moment I cannot test it myself as I cannot use my laptop.
I am sure that import static EnumKindOfThing.*; would work as the enum is seen as a static nested class. However I would like to know the exact above posted example.
Thanks in advance.