The example of this article tells the Java enumeration category usage. Share it for everyone for your reference. The specifics are as follows:
package com.school.sterotype; /*** Activity enumeration type* @AutHor qixuan.chen* /Public Enum Eventstatus { /*** is not published. * / Draw ("DRAFT", "Unpublished"), / *** Published. * / Published ("Public", "Published"); / *** Value of the Status of Mobility. * / private string value; / *** Chinese description of activity status. */ Private String Text;/ *** @Param Status Value* @Param Desc Chinese Description*/ Private Eventstatus (String Status, String Desc) {Value = Status; TEXT. = desc;} /** * @Return currently enumerate the value of the object. * / Public String GetValue () {Return value;} / *** @Return currently describes Chinese description. * / Public String Gettext () {Return Text;} / *** Get enumeration objects according to the value of the active state. ** @Param Status Event Status value* @Return enumeration object*/ Public Static Eventstatus Getinstance (String Status) {Eventstatus [] allStatus = Eventstatus.Values (); Status WS: Allstatus) {if (WS.GetValue () .qualSignorecase (Status) {Return WS;}} Throw New illegalargumentexception ("Status value illegal, no enumeration objects that meet the course status");}}
It is hoped that this article is helpful to everyone's Java program design.