Enum Usage:
Use Case 1:
Public enumENUM1 {//Yahoo Headline News RSS seedsYahoo_top_stories ("Http://rss.news.yahoo.com/rss/topstories"), //CBS Headline News RSS seedsCbs_top_stories ("Http://feeds.cbsnews.com/CBSNewsMain?format=xml"), //Los Angeles Times Headline News RSS seedsLatimes_top_stories ("Http://feeds.latimes.com/latimes/news?format=xml"); //enumerates the properties of an object's RSS address PrivateString Rss_url; //Enumerating Object Constructors Privatenewsrssfeedenum (String rss) { This. Rss_url =RSS; } //enumeration objects How to get an RSS address PublicString Getrssurl () {return This. Rss_url; }}
Use Case 2:
Public enum Enum2 { // Yahoo Headline news RSS seed yahoo_top_stories, //CBS Headline News RSS seed cbs_top_stories, // Los Angeles Times Headline News RSS seed latimes _top_stories; Public String}
However, there are several places to note when using Enum:
The enum type does not support the construction of the public and protected modifiers, so constructors must be private or friendly. Because of this, the enumeration object cannot be initialized in the program by directly invoking its constructor method.
When defining an enum type, if it is a simple type, then the last enumeration value is not followed by any symbol, but if there is a custom method, then the last enumeration value will be separated from the following code with a semicolon '; ' Separated, cannot use commas or spaces.
Because the value of the enum type is actually represented by the runtime construction object, each virtual machine constructs a synonym enumeration object in the cluster environment. Use switch as much as possible to determine
Java enum use case