niedziela, 4 września 2011

ENUMS

  • Enum when defined in the java file (outer version):
    can be only: public, default or strictfp
    cannot be: static, final, private, protected and abstract
  • Enum defined within other class (inner version):
    can be: public, protected, default, private, strictfp and static!!!
    cannot be final, abstract
  • Inner enums are by default static!

    class A {
        private enum E {}
    }

    is the same as:

    class A {
       private static enum E{}
    }

  • Enums cannot be defined inside methods (there is no inner local method enum  like e.g. inner local method class, by the way you cannot declare interfaces within method too)
-----------------------------------------------------------------------------------------------------------
enum ENUM {XX};
System.out.println("XX" == ENUM.XX.name());   //prints true!

Brak komentarzy:

Prześlij komentarz