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. class A {
  8. private int x;
  9.  
  10. public A(int x1)
  11. {
  12. this.x = x1;
  13. }
  14.  
  15. public int compare(A other)
  16. {
  17. return (this.x > other.x) ? 1 : (this.x == other.x ? 0 : -1);
  18. }
  19. }
  20.  
  21. /* Name of the class has to be "Main" only if the class is public. */
  22. class Ideone
  23. {
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. A o1 = new A(12);
  27. A o2 = new A(13);
  28.  
  29. System.out.println(o1.compare(o2));
  30. }
  31. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
-1