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("IOS1 class name = " + IosDevice.IOS1.getClass().getName());
  13. System.out.println("IOS1 base class name = "
  14. + IosDevice.IOS1.getClass().getSuperclass().getName());
  15. IosDevice myIosDevice = IosDevice.IOS1;
  16. System.out.println(Arrays.toString(myIosDevice.getValues()));
  17. AndroidDevice myAndroidDevice = AndroidDevice.AND1;
  18. System.out.println(Arrays.toString(myAndroidDevice.getValues()));
  19. }
  20. }
  21.  
  22. enum IosDevice implements IDevice {
  23. IOS1, IOS2;
  24.  
  25. public IDevice[] getValues() {
  26. return IosDevice.values();
  27. }
  28. }
  29.  
  30. enum AndroidDevice implements IDevice {
  31. AND1, AND2;
  32.  
  33. public IDevice[] getValues() {
  34. return AndroidDevice.values();
  35. }
  36. }
  37.  
  38. interface IDevice {
  39. //...
  40. public IDevice[] getValues();
  41. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
IOS1 class name = IosDevice
IOS1 base class name = java.lang.Enum
[IOS1, IOS2]
[AND1, AND2]