Enum Enum class

Source: Internet
Author: User
Enum Enum class

1.values ()
Description: The values () method returns a collection of enumeration classes that do not exist in the Enum class and are added by the compiler dynamically.

2.valueOf ()
Description: valueof () returns an object of the specified name in the enumeration class, case-sensitive.

Enumnametest.valueof ("READ"). CompareTo (Enumnametest.read) will return 0

3.compareTo ()
Description: Compares two enumerated objects is not the same, returns the same 0, not the same return-1

Enumnametest.valueof ("READ"). CompareTo (Enumnametest.write) will return-1

4.getDeclaringClass ()
Description: Returns the class object for this enumeration constant, enum type

5.ordinal ()
Description: Returns the position of this enumeration type, in order

Public enum  enumnametest {
    read,write
}

EnumNameTest.READ.ordinal () will return 0
EnumNameTest.WRITE.ordinal () will return 1

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.