fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Test {
  5. public enum Type { ExA, ExB, ExC }
  6.  
  7. Type t;
  8.  
  9. public Test(int num) {
  10. switch (num) {
  11. case 1:
  12. t = Type.ExA;
  13. break;
  14. case 2:
  15. t = Type.ExB;
  16. break;
  17. default:
  18. t = Type.ExC;
  19. break;
  20. }
  21. }
  22.  
  23. public Type getType() {
  24. return t;
  25. }
  26.  
  27.  
  28. }
  29.  
  30. class Main {
  31. public static void main (String[] args) throws java.lang.Exception {
  32. Test a = new Test(2);
  33.  
  34. System.out.println("a: " + a.getType());
  35. }
  36. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
a: ExB