In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the relevant knowledge points of Java enumeration?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Define
There are only a limited number of objects in the class.
Week: Monday (Monday),., Sunday (Sunday)
Gender: Man (male), Woman (female)
Season: Spring (Spring Festival). Winter (winter)
Payment methods: Cash (cash), WeChatPay (Wechat), Alipay (Alipay), BankCard (silver)
Bank Card), CreditCard (Credit Card)
Order status: Nonpayment (unpaid), Paid (paid), Delivered (shipped), Return (return), Checked (confirmed) Fulfilled (shipped),
Thread state: create, ready, run, block, die
Enum
The properties of enumerated class objects should not be allowed to be changed, so you should use private final decorations
The private final-decorated properties of the enumerated class should be assigned a value in the constructor
if the enumeration class explicitly defines a constructor with parameters, then the enumeration value must also correspond to the
Incoming parameter
Class Season {name of private final String SEASONNAME;// season description of private final String SEASONDESC;// season private Season (String seasonName,String seasonDesc) {this.SEASONNAME = seasonName;this.SEASONDESC = seasonDesc;} public static final Season SPRING = new Season ("spring", public static final Season SUMMER = new Season ("summer", public static final Season AUTUMN = new Season ("autumn", public static final Season WINTER = new Season ("winter",} "warm spring flowers"); "hot summer"); "crisp autumn") "Snow"); method
The values () method returns an array of objects of enumerated types. This method can easily traverse all the
Enumerated values.
ValueOf (String str): you can convert a string to the corresponding enumerated class object. Required character
The string must be the name of the enumerated class object. If not, there will be a runtime exception: IllegalArgumentException.
ToString (): returns the name of the current enumeration class object constant
This is the end of the content of "what are the relevant knowledge points of Java enumeration". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.