Enum Type as a Nested Enum Type Inside a Class - Java Language Basics

Java examples for Language Basics:enum

Description

Enum Type as a Nested Enum Type Inside a Class

Demo Code

public class Main {
  public static void main(String[] args) {
    Person.Gender m = Person.Gender.MALE;
    Person.Gender f = Person.Gender.FEMALE;
    System.out.println(m);//from   www.  j a  v a  2 s.  c  o m
    System.out.println(f);
  }
}

class Person {
  public enum Gender {
    MALE, FEMALE
  }
}

Result


Related Tutorials