Syntax and usage of enumerations in Java

Source: Internet
Author: User

In the company code, with a lot of enumeration, I am very confused to see. Let's start by looking at how enumerations are written and how to use them. First, the enumeration of the wording of the enumeration, online a lot of this knowledge. Here is a code for the enumeration class that I write myself directly.
  
  1. package com.tomtop.application.libraries.constentEnum;
  2. /**
  3. * 包材领用状态枚举类
  4. * @author zeng.xiao.yan
  5. * @date Jun 5, 2017 1:04:40 PM
  6. * @version V1.0
  7. */
  8. public enum UseStatusEnum {
  9. PACKING_NOT_USE(1), // 未领用
  10. PACKING_HAS_USED(2), // 已领用
  11. PACKING_BACK_USE(3); // 已打回
  12. private Integer useStatus;
  13. private UseStatusEnum(int useStatus) {
  14. this.useStatus = useStatus;
  15. }
  16. public Integer getUseStatus() {
  17. return useStatus;
  18. }
  19. }

Ii. usage of enumeration classes in code
 
   
  1. productPackingRecord.setUseStatus(UseStatusEnum.PACKING_NOT_USE.getUseStatus()); //设为未领用状态
Note: This method is called Getusestatus to return the value of the enumeration constant.
Reference Link: http://blog.csdn.net/u014527058/article/details/52751488 http://blog.csdn.net/qiyueqing lian/article/details/50738548


To be continued ...

Syntax and usage of enumerations in Java

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.