e1087. 用For循环做数组的遍历
Posted borter
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e1087. 用For循环做数组的遍历相关的知识,希望对你有一定的参考价值。
The for
statement can be used to conveninently iterate over the elements of an array. The general syntax of the array-based for
statement is:
for (type variable : array) { body-code }
The array-based for
statement has four parts. The array is an expression that returns an array. The type specifies the type of variable which will be used to hold elements from the array. In particular, variable always holds the current element of the iteration and can be used by the code in body-code. body-code is code that will be executed once for every element in the array. Here is an example of the for
statement.
// Returns the smallest integer in the supplied array public int getMin(int[] ints) { int min = Integer.MAX_VALUE; for (int num : ints) { if (num < min) { min = num; } } return min; }
Related Examples |
以上是关于e1087. 用For循环做数组的遍历的主要内容,如果未能解决你的问题,请参考以下文章