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(ch & Character.A)
{
// some operation...
}
for example if ch
set to Character.B
then result of if
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?
See Question&Answers more detail:os