[java] Number for each enum item?
Is it possible to define something like this in java?

C# code:

    public enum Character
    {
        A = 1,
    
        B = 2,
    
        C = 4,
    
        D = 8
    
    }


    ...
    
    Character ch = /* from user */
    
    if(c & Character.A)
    {
        // some operation...
    }


for example if `ch` set to `Character.B` then result will be false:

    ch = 00000000 00000000 00000000 00000010
    A  = 00000000 00000000 00000000 00000001
    ------------------------------------------
    &    00000000 00000000 00000000 00000000

I want to implement something like that! Is it ever possible in Java?
[java] Number for each enum item?
===

Is it possible to define something like this in java?

C# code:

    public enum Character
    {
        A = 1,
    
        B = 2,
    
        C = 4,
    
        D = 8
    
    }


    ...
    
    Character ch = /* from user */
    
    if(c & Character.A)
    {
        // some operation...
    }


for example if `ch` set to `Character.B` then result will be false:

    ch = 00000000 00000000 00000000 00000010
    A  = 00000000 00000000 00000000 00000001
    ------------------------------------------
    &    00000000 00000000 00000000 00000000

I want to implement something like that! Is it ever possible in Java?