fork download
  1. public class Max {
  2. public static Object max(java.lang.Comparable[] a) {
  3.  
  4. Object tempObj = new Object();
  5.  
  6. for (int i = 0; i < a.length - 1; i++) {
  7. if ((a[i]).compareTo(a[i + 1]) > 0)
  8. tempObj = a[i];
  9. else
  10. tempObj = a[i + 1];
  11. }
  12.  
  13. return tempObj;
  14. }
  15.  
  16. // compare toMethod
  17. public void CompareTo() {
  18. a[i].compareTo(a[i + 1]);
  19. }
  20. }// End Main
  21.  
  22. class MaxTest implements Max {
  23. public void main(String[] args) {
  24.  
  25. Integer[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  26. String[] stringArray = { "a", "b", "c", "d", "e", "f", "g", "h", "i",
  27. "j" };
  28. java.util.Date[] dateArray = {};
  29.  
  30. for (int j = 0; j < 10; j++)
  31. dateArray[j] = new java.util.Date();
  32.  
  33. }// End Main
  34. }//End Class
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class Max is public, should be declared in a file named Max.java
public class Max {
       ^
Main.java:22: error: interface expected here
class MaxTest implements Max {
                         ^
Main.java:18: error: cannot find symbol
        a[i].compareTo(a[i + 1]);
                       ^
  symbol:   variable a
  location: class Max
Main.java:18: error: cannot find symbol
        a[i].compareTo(a[i + 1]);
                         ^
  symbol:   variable i
  location: class Max
Main.java:18: error: cannot find symbol
        a[i].compareTo(a[i + 1]);
        ^
  symbol:   variable a
  location: class Max
Main.java:18: error: cannot find symbol
        a[i].compareTo(a[i + 1]);
          ^
  symbol:   variable i
  location: class Max
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
stdout
Standard output is empty