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.  
  11. static class A implements Comparable<A> {
  12.  
  13.  
  14. @Override
  15. public int compareTo(A a) { return 0;}
  16.  
  17. public Integer compareTo(Object o) {
  18. return Integer.valueOf(1);}
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. // your code goes here
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: name clash: compareTo(A) in A overrides a method whose erasure is the same as another method, yet neither overrides the other
    public int compareTo(A a) { return 0;}
               ^
  first method:  compareTo(Object) in A
  second method: compareTo(T) in Comparable
  where T is a type-variable:
    T extends Object declared in interface Comparable
Main.java:17: error: name clash: compareTo(Object) in A and compareTo(T) in Comparable have the same erasure, yet neither overrides the other
    public Integer compareTo(Object o) {
                   ^
  where T is a type-variable:
    T extends Object declared in interface Comparable
2 errors
stdout
Standard output is empty