Page 1 of 1

In JAVA, create an enum with 4 colors blue, green, purple, and red together with these 2 methods.

Posted: Sun Jul 10, 2022 11:27 am
by answerhappygod
In JAVA, create an enum with 4 colors blue, green, purple, andred together with these 2 methods.
In Java Create An Enum With 4 Colors Blue Green Purple And Red Together With These 2 Methods 1
In Java Create An Enum With 4 Colors Blue Green Purple And Red Together With These 2 Methods 1 (33.65 KiB) Viewed 72 times
Method Detail values public static Color[] values() Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows: for (Color c: Color.values()) System.out.println(c); Returns: an array containing the constants of this enum type, in the order they are declared valueOf public static Color valueof(java.lang.String name) Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) Parameters: name the name of the enum constant to be returned. Returns: the enum constant with the specified name Throws: java.lang.IllegalArgumentException - if this enum type has no constant with the specified name java.lang.NullPointerException - if the argument is null