fork download
  1. package com.bibus;
  2.  
  3.  
  4.  
  5. import javafx.util.Pair;
  6.  
  7. import java.time.LocalDate;
  8.  
  9. public class Main {
  10.  
  11. public static void main(String[] args) {
  12. LocalDate[] birthdays =
  13. {
  14. LocalDate.of(1996,12,9),
  15. LocalDate.of(1896,2,9),
  16. LocalDate.of(1992,1,10),
  17. LocalDate.of(1965,3,4),
  18.  
  19. };
  20. Pair<LocalDate> mm = ArrayAlg.minmax(birthdays);
  21. System.out.println("min = "+mm.getFirst());
  22. System.out.println("max = "+mm.getSecond());
  23.  
  24. }
  25. }
  26.  
  27. class ArrayAlg
  28. {
  29.  
  30. public static <T extends Comparable>Pair<T> minmax(T[] a)
  31. {
  32. if (a==null || a.length ==0) return null;
  33. T max = a[0];
  34. T min = a[0];
  35. for(int i = 0; i<a.length; i++){
  36. if(min.compareTo(a[i])>0)min = a[i];
  37. if(max.compareTo(a[i])<0)max = a[i];
  38. }
  39. return new Pair<>(min,max);
  40. }
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:30: error: cannot find symbol
    public static <T extends Comparable>Pair<T> minmax(T[] a)
                                        ^
  symbol:   class Pair
  location: class ArrayAlg
Main.java:20: error: cannot find symbol
        Pair<LocalDate> mm = ArrayAlg.minmax(birthdays);
        ^
  symbol:   class Pair
  location: class Main
Main.java:39: error: cannot find symbol
        return new Pair<>(min,max);
                   ^
  symbol:   class Pair
  location: class ArrayAlg
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
stdout
Standard output is empty