How to change an enum at runtime (Java) -
this question has answer here:
basically, writing addon minecraft mod called aura cascade. aura cascade adds aura (as name suggests), comes in different colors. wanted add colors of aura, valid colors defined in enum this:
public enum enumaura{white,black,red,orange,yellow,green,blue,purple}
how add values enumaura @ runtime?
to clarify, of code must run after aura cascade initialized.
if understand question correctly, can't that.
please take java documentation enums : https://docs.oracle.com/javase/tutorial/java/javaoo/enum.html
enum types
an enum type special data type enables variable set of predefined constants. variable must equal 1 of values have been predefined it. common examples include compass directions (values of north, south, east, , west) , days of week.
because constants, names of enum type's fields in uppercase letters.
in java programming language, define enum type using enum keyword. example, specify days-of-the-week enum type as:
public enum day { sunday, monday, tuesday, wednesday, thursday, friday, saturday }
you should use enum types time need represent fixed set of constants. includes natural enum types such planets in our solar system , data sets know possible values @ compile time—for example, choices on menu, command line flags, , on.
Comments
Post a Comment