The enumerations in Java and. NET are different, In. NET, enumerations are value types, and in Java they do reference types (in fact a special class, enums integrate the Java.lang.Enum class by default), so manipulating enumeration types in Java is not as convenient in. NET, for example: in. NET, you can simply assign values to enumerations, or you can It is very convenient to force type conversions, and in Java it is not possible to do this because it is a reference type, and the following are some of the features in Java that implement enumerated types in. NET, as follows:
enumsearson{Spring ("Spring", 2), Summer ("Xia", 4), Wall ("Autumn", 6), Winter ("Winter", 8); Private FinalString desc; Private Final intvalue; PrivateSearson (String desc,intvalue) { This. desc =desc; This. Value =value; } PublicString GetDesc () {return This. Desc; } Public intGetValue () {return This. Value; } }
Java implementation of enumerations in. Net