【发布时间】:2014-10-09 14:42:50
【问题描述】:
public long getMax() // get maximum value
{
if (nelems == 0) {
return -1;
}
long lngMax = arr[0];
for (int j = 1; j < nelems; j++) {
if (lngMax < arr[j]) {
lngMax = arr[j];
}
}
return lngMax;
}
这个方法返回数组中的最大值。我应该在这里写什么逻辑,而不是返回值,它返回最大值的位置而不使用java中的任何内置方法? 很抱歉提出愚蠢的问题。
【问题讨论】:
-
@Joe 我已经提到没有内置方法