Mencari nilai minimum dan nilai maksimum dalam tatasusunan satu dimensi
/**
*
MENCARI NILAI MINIMUM DAN NILAI MAKSIMUM DARIPADA SENARAI ELEMEN DALAM
TATASUSUNAN
*/
import java.util.Arrays;
import java.util.Collections;
public class FindingMaxMinUsingArray {
public static void
main(String[] args) {
Integer[] numbers = { 8,
2, 7, 1, 4, 9, 5};
int min = (int)
Collections.min(Arrays.asList(numbers));
int max = (int)
Collections.max(Arrays.asList(numbers));
System.out.println("Min number: " + min);
System.out.println("Max number: " + max);
}
}
|
Welcome to DrJava. Working
directory is D:\CODING DRJAVA
> run FindingMaxMinUsingArray
Min number: 1
Max number: 9
>
|
0 comments:
Post a Comment