23 * have any questions. 24 */ 25 26 package java.lang; 27 28 import java.io.Serializable; 29 import java.io.IOException; 30 import java.io.InvalidObjectException; 31 import java.io.ObjectInputStream; 32 import java.io.ObjectStreamException; 33 34 /** 35 * This is the common base class of all Java language enumeration types. 36 * 37 * More information about enums, including descriptions of the 38 * implicitly declared methods synthesized by the compiler, can be 39 * found in <i>The Java™ Language Specification, Third 40 * Edition</i>, <a 41 * href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9">§8.9</a>. 42 * 43 * @param <E> The enum type subclass 44 * @author Josh Bloch 45 * @author Neal Gafter 46 * @see Class#getEnumConstants() 47 * @since 1.5 48 */ 49 public abstract class Enum<E extends Enum<E>> 50 implements Comparable<E>, Serializable { 51 /** 52 * The name of this enum constant, as declared in the enum declaration. 53 * Most programmers should use the {@link #toString} method rather than 54 * accessing this field. 55 */ 56 private final String name; 57 58 /** 59 * Returns the name of this enum constant, exactly as declared in its 60 * enum declaration. 61 * 62 * <b>Most programmers should use the {@link #toString} method in 63 * preference to this one, as the toString method may return 64 * a more user-friendly name.</b> This method is designed primarily for 65 * use in specialized situations where correctness depends on getting the 66 * exact name, which will not vary from release to release. | 23 * have any questions. 24 */ 25 26 package java.lang; 27 28 import java.io.Serializable; 29 import java.io.IOException; 30 import java.io.InvalidObjectException; 31 import java.io.ObjectInputStream; 32 import java.io.ObjectStreamException; 33 34 /** 35 * This is the common base class of all Java language enumeration types. 36 * 37 * More information about enums, including descriptions of the 38 * implicitly declared methods synthesized by the compiler, can be 39 * found in <i>The Java™ Language Specification, Third 40 * Edition</i>, <a 41 * href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9">§8.9</a>. 42 * 43 * <p> Note that when using an enumeration type as the type of a set 44 * or as the type of the keys in a map, specialized and efficient 45 * {@linkplain java.util.EnumSet set} and {@linkplain 46 * java.util.EnumMap map} implementations are available. 47 * 48 * @param <E> The enum type subclass 49 * @author Josh Bloch 50 * @author Neal Gafter 51 * @see Class#getEnumConstants() 52 * @see java.util.EnumSet 53 * @see java.util.EnumMap 54 * @since 1.5 55 */ 56 public abstract class Enum<E extends Enum<E>> 57 implements Comparable<E>, Serializable { 58 /** 59 * The name of this enum constant, as declared in the enum declaration. 60 * Most programmers should use the {@link #toString} method rather than 61 * accessing this field. 62 */ 63 private final String name; 64 65 /** 66 * Returns the name of this enum constant, exactly as declared in its 67 * enum declaration. 68 * 69 * <b>Most programmers should use the {@link #toString} method in 70 * preference to this one, as the toString method may return 71 * a more user-friendly name.</b> This method is designed primarily for 72 * use in specialized situations where correctness depends on getting the 73 * exact name, which will not vary from release to release. |