Finding the max/min value in an array of primitives using Java

前端 未结 15 2066
遥遥无期
遥遥无期 2020-11-22 05:09

It\'s trivial to write a function to determine the min/max value in an array, such as:

/**
 * 
 * @param chars
 * @return the max value in the array of chars         


        
15条回答
  •  没有蜡笔的小新
    2020-11-22 05:17

    Here's a utility class providing min/max methods for primitive types: Primitives.java

    int [] numbers= {10,1,8,7,6,5,2};
        int a=Integer.MAX_VALUE;
        for(int c:numbers) {
            a=c

提交回复
热议问题