当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java IntSummaryStatistics getMax()用法及代码示例


Java中IntSummaryStatistics类的getMax()方法用于获取此IntSummaryStatistics中的最大记录数。

用法:

public int getMax()

参数:此方法不接受任何值作为参数。


返回值:此方法返回此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 maximum of values is "
                           + intSummaryStatistics.getMax()); 
    } 
}
输出:
The maximum of values is 50

参考: https://docs.oracle.com/javase/10/docs/api/java/util/IntSummaryStatistics.html#getMax()



相关用法


注:本文由纯净天空筛选整理自ShubhamMaurya3大神的英文原创作品 IntSummaryStatistics getMax() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。