您的位置:首页 >Java中如何遍历数组元素?
发布于2023-04-30 阅读(0)
扫一扫,手机访问
说明
1、分别从数组中获取每一个元素,即遍历。在数组操作中,遍历也是基石。
2、数组中的每一个元素都可以被广泛使用,但如果数组元素很多,这种写法肯定是不行的,所以需要改为循环写法。
实例
数组索引为0-lenght-1,可作为循环条件出现。
public class ArrayTest01 {
public static void main(String[] args) {
int[] arr = { 1, 2, 3, 4, 5 };
System.out.println(arr[0]);
System.out.println(arr[1]);
System.out.println(arr[2]);
System.out.println(arr[3]);
System.out.println(arr[4]);
}
}
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
9