Java IntSummaryStatistics getMin()方法及示例
Java中IntSummaryStatistics类 的 getMin() 方法用于获取该IntSummaryStatistics中的最小记录。
语法。
public int getMin()
参数。该方法不接受任何值作为参数。
返回值。该方法返回IntSummaryStatistics中的最小记录。
程序。
// Java program to demonstrate
// the above method
import java.util.*;
public class IntSummaryStatisticsDemo {
public static void main(String[] args)
{
IntSummaryStatistics intSummaryStatistics
= new IntSummaryStatistics();
List<Integer> list
= Arrays.asList(10, 20, 30, 40, 50);
Iterator<Integer> iterator = list.listIterator();
while (iterator.hasNext()) {
// Add the integers to the IntSummaryStatistics object
intSummaryStatistics.accept(iterator.next());
}
System.out.println("The minimum of values is "
+ intSummaryStatistics.getMin());
}
}
输出。
The minimum of values is 10
**参考资料: ** https://docs.oracle.com/javase/10/docs/api/java/util/IntSummaryStatistics.html#getMin()