for문과 while문 같은경우 알것 같기에 생략하였습니다.
import java.util.List;
public class Main {
public static void main(String[] args) {
Integer[] i = {1, 2, 4, 5, 6, 11, 6, 1};
List<Integer> list = List.of(i);
int max = list.stream().max(Integer::compare).get();
System.out.println(max);
}
}
출력
11
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] args) {
Integer[] i = {1, 2, 4, 5, 6, 11, 6, 1};
List<Integer> list = List.of(i);
int max = Collections.max(list);
System.out.println(max);
}
}
출력
11
import java.util.List;
public class Main {
public static void main(String[] args) {
Integer[] i = {1, 2, 4, 5, 6, 11, 6, 1};
List<Integer> list = List.of(i);
int max = list.stream().min(Integer::compare).get();
System.out.println(max);
}
}
출력
1
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] args) {
Integer[] i = {1, 2, 4, 5, 6, 11, 6, 1};
List<Integer> list = List.of(i);
int max = Collections.min(list);
System.out.println(max);
}
}
출력
1