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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(
  13. PacketType.REFUSAL.toString()
  14. + " = "
  15. + PacketType.REFUSAL.getByteCode()
  16. ) ;
  17. }
  18. }
  19.  
  20. enum PacketType {
  21. ACCEPTANCE ( (byte) 101 ), // Calling constructor on this enum class.
  22. REFUSAL ( (byte) 42 ) ;
  23.  
  24. private byte byteCode ; // Member field.
  25.  
  26. PacketType ( byte b ) { this.byteCode = b ; } // Constructor.
  27.  
  28. byte getByteCode() { return this.byteCode ; } // Getter method, for a read-only property of this enum.
  29.  
  30. }
Success #stdin #stdout 0.18s 36160KB
stdin
Standard input is empty
stdout
REFUSAL = 42