Java implementation of enumerations in. Net

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.