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

最新文章

  1. Android 蓝牙API详解
  2. Java关键字final、static使用总结
  3. jquery中的$(document).ready()、JavaScript中的window.onload()以及body中的onload()的区别
  4. HDU5898、 HDU 2089(数位DP)
  5. 使用struts2的&lt;s&gt;标签出错
  6. HW7.17
  7. python学习--string
  8. C语言学习笔记--结构体
  9. unix c 10
  10. PV IP UV
  11. Ubuntu系统下配置IP地址方法介绍
  12. 2018最新iOS端界面UI设计规范整理
  13. 给定数组长度2n,分成n对,求n对最小元素之和最大
  14. Django项目的创建
  15. 关于setvbuf()函数的详解
  16. TensorFlow安装之后导入报错:libcudnn.so.6:cannot open sharedobject file: No such file or directory
  17. CF1110E Magic Stones(构造题)
  18. go语言之进阶篇数组越界导致panic
  19. Android -- 触摸Area对焦区域(更新)
  20. canvas线性变换、颜色和样式选择

热门文章

  1. python pandas 计算相关系数
  2. 如何理解Latency和Throughput: 吞吐量和延迟
  3. html中如何让table显示的更好
  4. Java 并发
  5. 飘逸的python - 几行代码实现unix管道风格的函数调用
  6. How to Acquire or Improve Debugging Skills
  7. c语言double类型数据四舍五入
  8. 对JAVASCRIPT匿名函数的理解
  9. ELK的索引的坑——Kibana的图形化(Tile Map)
  10. 路由器的LAN口和WAN口有什么区别