Java data type of the enumeration

1. Scene

  Variable takes only several fixed values, such as the size of the garment is only small, medium, large, large can use four kinds of the enumeration.

2. Define, declare enumerated types

  (1) Definition:

    enum Size {SMALL,MEDIUM,LARGE,EXTRA_LARGE};

    (2) Statement:

    Size s = Size.SMALL;

    Description: Size type null value or a variable store only defined above.

    

Guess you like

Origin www.cnblogs.com/quanhaijie/p/12163387.html