遍历:一个一个访问
package com.itheima.arry; public class ArryDemo2 { public static void main(String[] args) { //掌握数组遍历 int[] ages=new int[]{12,24,36}; // System.out.println(ages[0]); // System.out.println(ages[1]); // System.out.println(ages[2]); for(int i=0;i<ages.length;i++){ System.out.println(ages[i]); } //输入ages.fori回车即可快速进行数组遍历 for (int i = 0; i < ages.length; i++) { } } }
案例:
package com.itheima.arry; public class ArrayDemo3 { public static void main(String[] args) { int[] money=new int[]{16,26,36,6,100}; int all=0; for (int i = 0; i < money.length; i++) { all=all+money[i]; } System.out.println(all); } }
标签:遍历,JAVA,int,ages,System,数组,println,public,out From: https://www.cnblogs.com/pengsuoqun123/p/18041700