Page 1 of 1

Enum static import

Posted: Tue Aug 27, 2013 3:31 am
by The_Nick
Hi everybody,
Having an enum declared within a class:

Code: Select all

public class EnumKindOfThing{
public enum Days{MONDAY,SUNDAY};

}
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.

Re: Enum static import

Posted: Wed Aug 28, 2013 10:28 am
by The_Nick
Solved, yes it works.

The_Nick.