fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. private static Map<Byte, OpCode> valueToOpCode = new HashMap<>();
  11.  
  12. static OpCode getOpCode(byte value) {
  13. return valueToOpCode.get(value);
  14. }
  15.  
  16. public static enum OpCode {
  17. a((byte) 0x0),
  18. b((byte)0x18),
  19. c((byte)0x1A);
  20.  
  21. private byte value;
  22.  
  23. OpCode(byte value) {
  24. this.value = value;
  25. valueToOpCode.put(value, this);
  26. }
  27.  
  28. byte getValue() {
  29. return value;
  30. }
  31.  
  32. }
  33.  
  34. public static void main(String[] args) {
  35. byte x = 0x18;
  36. System.out.println(getOpCode(x)); // prints 'b'
  37. }
  38. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
null