Should Android app development avoid using enumerations?

Source: Internet
Author: User

Prior to the Android Froyo version , the official document performance tips had "Avoid Enums Where you are only need Ints" and later that part was removed , see Per Formance Tips

Android VM Team Elliott Hughes clarified the issue on StackOverflow , details

He pointed out that "the original document has been updated based on the actual evaluation of the virtual machine (Benchmark) , leaving only the results of the evaluation, and with the update of the Froyo version of the virtual machine , the document has also been updated .

Moreover , Avoid Enums Where you are only need ints is intended to refer to an event where an int should be used , you should avoid using enumerations . When you find that you often call the ordinal () method , Consider whether you should use Int. "

So , in Android app Development , it is possible to use enumerations .

However , from the memory point of view, it is important to note that the enumeration brings advantages, and it does use more memory than int .

In another website document on memory optimization ( details ) , there is still a saying to avoid using enumerations .

Should Android app development avoid using enumerations?

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.