fork download
  1. public class Demo_Largest {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. ArrayList<Integer> list = new ArrayList<>();
  6.  
  7. for (int i = 0; i < 10; i++) {
  8. list.add(i);
  9. }
  10. System.out.println(max(list));
  11.  
  12. }
  13.  
  14. public static <E extends Comparable<E>> E max(ArrayList<E> list) {
  15. E max = list.get(0);
  16.  
  17. for (int i = 1; i < list.size(); i++) {
  18. if (list.get(i).compareTo(max) > 0) {
  19. max = list.get(i);
  20. }
  21. }
  22.  
  23. return max;
  24. }
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class Demo_Largest is public, should be declared in a file named Demo_Largest.java
public class Demo_Largest {
       ^
Main.java:14: error: cannot find symbol
    public static <E extends Comparable<E>> E max(ArrayList<E> list) {
                                                  ^
  symbol:   class ArrayList
  location: class Demo_Largest
Main.java:5: error: cannot find symbol
        ArrayList<Integer> list = new ArrayList<>();
        ^
  symbol:   class ArrayList
  location: class Demo_Largest
Main.java:5: error: cannot find symbol
        ArrayList<Integer> list = new ArrayList<>();
                                      ^
  symbol:   class ArrayList
  location: class Demo_Largest
4 errors
stdout
Standard output is empty