Java – when to create an Enum instance?
•
Java
I have a simple question about enumeration in Java. Please refer to the following code When to instantiate propname Contents and other examples?
public enum PropName { CONTENTS("contents"),USE_QUOTES("useQuotes"),ONKEYDOWN("onkeydown"),BROWSER_ENTIRE_TABLE("browseEntireTable"),COLUMN_headingS("columnheadings"),PAGE_SIZE("pageSize"),POPUP_TITLE("popupTitle"),FILTER_COL("filterCol"),sql_SELECT("sqlSelect"),; private String name; private PropName(String name) { this.name = name; } public String getName() { return name; } }
Solution
It is created when the class is loaded, just like any static code block
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码