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. static enum Fruit { Apple, Orange, Banana };
  11. static enum Animal { Cat, Dog, Horse };
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. try {
  15. Enum f = Fruit.Apple;
  16. Comparable a = Animal.Cat; // if Enum then line 55 will not appear in trace
  17. f.compareTo(a);
  18. } catch (Exception x) {
  19. x.printStackTrace(System.out);
  20. }
  21. }
  22. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
java.lang.ClassCastException
	at java.lang.Enum.compareTo(Enum.java:180)
	at java.lang.Enum.compareTo(Enum.java:55)
	at Ideone.main(Main.java:17)