package com.caohao.shizhan; public class shizhan1 { public static void main(String[] args) { //创建鸟类数组 String[] aves=new String[]{"白鹿","丹顶鹤","黄鹤","鹦鹉","乌鸦","喜鹊","布谷鸟","灰纹鸟","白灵鸟"}; //创建索引变量 int idex=0; System.out.println("我的花园里面有很多鸟,种类大约包括:"); //遍历数组 while (idex<aves.length){ //自增索引值 System.out.println(aves[idex++]); } } }
使用While与自运算符循环遍历数组
最新推荐文章于 2022-06-05 12:11:36 发布