instance « enum « Java Data Type Q&A

1. Follow up: instance control in Java without enum

This is a follow up to this question. Is this solution watertight?

public final class Thing implements Serializable {

    private static final long serialVersionUID = 1L;


2. It is related to core java enums

what is singleton instances of the enumeration class in java?

3. Java covariant return types not working for overridding methods of an enum instance?

I spent quite a while with Google to find some information on this topic, but results relating to both Java enums and covariant return types were pretty much non-existant. So: is it ...

4. How to specify default Enum instance for Guice?

I'd need something like

which would make Guice to return Level.NORMAL for the expression
There's no such thing like @DefaultInstance. As a workaround I've tried @ProvidedBy with a trivial ...

5. Enums: methods exclusive to each one of the instances

From another question I have learnt that it is possible in Java to define specific methods for each one of the instances of an Enum:

public class AClass {


6. EnumType foo: How do I write foo.changeme()?

Here's what I've written:

public class JavaApplication4 {
    private RunMode runMode;

    private enum RunMode {
        STOP, START, SCE, SIE;


7. Analysing java heapdumps: why are enum instances kept in heap?

I've been looking for memory leaks in my app and foud with jhat that for some reason instances of enumerations are kept in the heap. To simulate it, I have deployed my ...

8. get instance of Enum from name