object « enum « Java Data Type Q&A

1. Should enum objects be stateless?    stackoverflow.com

As by design an enum constant in java is a singleton, and for sake of concurrent usage I normally create stateless enum instances and use method parameters to inject the data ...

2. Why Java does not allow overriding equals(Object) in an Enum?    stackoverflow.com

I've noticed that the following snippet...

public boolean equals(Object otherObject) {
...is not allowed for an Enum, since the method equals(Object x) is defined as final in

3. Non-Null Enums like non-null Objects?    stackoverflow.com

I have some code that acquires a value for an enum:

The supporting code looks like this:
public CustomEnum getEnumMember() {
    return enumMember;


public enum CustomEnum {


4. Better way to convert from string to an enum object and vice-versa    stackoverflow.com

So I have the following enum and each state represents a string in a database table. In my methods which interact with the database and particularly the status field I'm simply ...

5. Is it possible to use upper scope object in Java enum?    stackoverflow.com

First class which got the enum:

public class EnumTest {

    private Employee empl;

    public EnumTest(Employee empl) {
        this.empl = ...

6. Using enum in remote object    coderanch.com

Hello folks, i do have a class where i use fields of type enum and get a java.io.NotSerializableException. As all the other fields are of a simple type (int, etc), i don't know, why this class isn't serializeable/remoteable. Maybe the enum is the problem. The class 'NoteImpl' is transfered between a client and a server using RMI. The class 'Note' is ...

7. Compare an Object to an Enum list    coderanch.com

Greetings All, My name is Declan and I am new to both Java programming, programming in general and of course this site. I hope to get to know you all in the coming years (!) My first question is this. I have the following two Enums: public enum CardSuit { SPADES, CLUBS, DIAMONDS, HEARTS } and public enum CardRank { DEUCE, ...

9. Creating a dynamic ENUM object?    forums.oracle.com

It's defeating the point of using an enum. It sounds like you just need a collection of regular old objects. What are the particular advantages of an enum that you were hoping you'd be using in doing this? I can't help wondering if the solution is just to be careful to override equals and hashcode properly.