foreach语句遍历数组
/**
*
* @author hws
* @date 2018-04-11
* foreach语句:
* 创建一个一位数组,并用foreach遍历出来
*/
public class ForeachTest {
public static void main(String[] args) {
int a[]= {1,2,3,4,5};
System.out.println("数组中的元素为:");
//foreach一般用来遍历数组,int x循环变量x,遍历对象a
for(int x:a){
System.out.print(x+" ");
}
}
*
* @author hws
* @date 2018-04-11
* foreach语句:
* 创建一个一位数组,并用foreach遍历出来
*/
public class ForeachTest {
public static void main(String[] args) {
int a[]= {1,2,3,4,5};
System.out.println("数组中的元素为:");
//foreach一般用来遍历数组,int x循环变量x,遍历对象a
for(int x:a){
System.out.print(x+" ");
}
}
}
运行结果图:
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: nginx 做mysql负载均衡
- 下一篇: Yii2增删改查-查询 where参数详细介绍