📜  带有 for 循环的数组 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:38.886000             🧑  作者: Mango

代码示例10
// Find-Max variant
// Use very small number, Integer.MIN_VALUE,
// as the initial max value.
public int findMax2(int[] nums) {
  int maxSoFar = Integer.MIN_VALUE;  // about -2 billion

  // Look at every element
  for (int i=0; i maxSoFar) {
      maxSoFar = nums[i];
    }
  }
  
  return maxSoFar;
}