• 코드:
​x
 
1
import java.util.OptionalInt;
2
import java.util.stream.*;
3
​
4
public class prog {
5
    public static void main(String[] args){
6
        IntStream stream1 = IntStream.of(4, 2, 7, 3, 5, 1, 6);
7
        IntStream stream2 = IntStream.of(4, 2, 7, 3, 5, 1, 6);
8
        
9
        OptionalInt result1 = stream1.sorted().findFirst();
10
        System.out.println(result1.getAsInt());
11
        
12
        OptionalInt result2 = stream2.sorted().findAny();
13
        System.out.println(result2.getAsInt());
14
    }
15
}
표준입력 & 실행옵션