package com.bibus ;
import javafx.util.Pair ;
import java.time.LocalDate ;
public class Main {
public static void main
( String [ ] args
) { LocalDate[ ] birthdays =
{
LocalDate.of ( 1996 ,12 ,9 ) ,
LocalDate.of ( 1896 ,2 ,9 ) ,
LocalDate.of ( 1992 ,1 ,10 ) ,
LocalDate.of ( 1965 ,3 ,4 ) ,
} ;
Pair< LocalDate> mm = ArrayAlg.minmax ( birthdays) ;
System .
out .
println ( "min = " + mm.
getFirst ( ) ) ; System .
out .
println ( "max = " + mm.
getSecond ( ) ) ;
}
}
class ArrayAlg
{
public static < T extends Comparable> Pair< T> minmax( T[ ] a)
{
if ( a== null || a.length == 0 ) return null ;
T max = a[ 0 ] ;
T min = a[ 0 ] ;
for ( int i = 0 ; i< a.length ; i++ ) {
if ( min.compareTo ( a[ i] ) > 0 ) min = a[ i] ;
if ( max.compareTo ( a[ i] ) < 0 ) max = a[ i] ;
}
return new Pair<> ( min,max) ;
}
}
cGFja2FnZSBjb20uYmlidXM7CgoKCmltcG9ydCBqYXZhZngudXRpbC5QYWlyOwoKaW1wb3J0IGphdmEudGltZS5Mb2NhbERhdGU7CgpwdWJsaWMgY2xhc3MgTWFpbiB7CgogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIExvY2FsRGF0ZVtdIGJpcnRoZGF5cyA9CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIExvY2FsRGF0ZS5vZigxOTk2LDEyLDkpLAogICAgICAgICAgICAgICAgICAgICAgICBMb2NhbERhdGUub2YoMTg5NiwyLDkpLAogICAgICAgICAgICAgICAgICAgICAgICBMb2NhbERhdGUub2YoMTk5MiwxLDEwKSwKICAgICAgICAgICAgICAgICAgICAgICAgTG9jYWxEYXRlLm9mKDE5NjUsMyw0KSwKCiAgICAgICAgICAgICAgICB9OwogICAgICAgIFBhaXI8TG9jYWxEYXRlPiBtbSA9IEFycmF5QWxnLm1pbm1heChiaXJ0aGRheXMpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigibWluID0gIittbS5nZXRGaXJzdCgpKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIm1heCA9ICIrbW0uZ2V0U2Vjb25kKCkpOwoKICAgIH0KfQoKY2xhc3MgQXJyYXlBbGcKewoKICAgIHB1YmxpYyBzdGF0aWMgPFQgZXh0ZW5kcyBDb21wYXJhYmxlPlBhaXI8VD4gbWlubWF4KFRbXSBhKQogICAgewogICAgICAgIGlmIChhPT1udWxsIHx8IGEubGVuZ3RoID09MCkgcmV0dXJuIG51bGw7CiAgICAgICAgVCBtYXggPSBhWzBdOwogICAgICAgIFQgbWluID0gYVswXTsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpPGEubGVuZ3RoOyBpKyspewogICAgICAgICAgICBpZihtaW4uY29tcGFyZVRvKGFbaV0pPjApbWluID0gYVtpXTsKICAgICAgICAgICAgaWYobWF4LmNvbXBhcmVUbyhhW2ldKTwwKW1heCA9IGFbaV07CiAgICAgICAgfQogICAgICAgIHJldHVybiBuZXcgUGFpcjw+KG1pbixtYXgpOwogICAgfQp9Cg==
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