增强for循环遍历数组
时间: 2023-09-05 15:12:09 浏览: 124
java代码-使用java增强for循环 string数组赋值的源代码
5星 · 资源好评率100%
增强for循环(也称为for-each循环)是一种用于遍历数组和集合的高级for循环。它在JDK1.5以后引入,并且内部使用了迭代器来实现遍历。增强for循环的语法格式如下:
```java
for (元素类型 变量名 : 数组/集合名){
// 循环体
}
```
对于一维数组的增强for循环遍历,可以使用以下方式:
```java
int[] arr = new int<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *2* [数组增强for循环遍历](https://blog.csdn.net/m0_52318340/article/details/125565326)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *3* [增强for循环的使用(数组和集合遍历尤为简单)](https://blog.csdn.net/m0_52646273/article/details/116669880)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文