就是將數組中的每個元素分別獲取出來,就是遍歷。遍歷也是數組操作中的基石。
數組的索引是 0 到 lenght-1 ,可以作為循環的條件出現
public class ArrayDemo4 { public static void main(String[] args) { int[] arr = {1, 3, 5, 7, 9}; //進行數組的遍歷 for (int i = 0; i < arr.length; i++){ System.out.println(arr[i]); } } }
就是將數組中的每個元素分別獲取出來,就是遍歷。遍歷也是數組操作中的基石。
數組的索引是 0 到 lenght-1 ,可以作為循環的條件出現
public class ArrayDemo4 { public static void main(String[] args) { int[] arr = {1, 3, 5, 7, 9}; //進行數組的遍歷 for (int i = 0; i < arr.length; i++){ System.out.println(arr[i]); } } }
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。