1. 程式人生 > >實例20 使用while循環語句與自增運算符循環遍歷數組

實例20 使用while循環語句與自增運算符循環遍歷數組

int highlight ack system port 使用 index ++ ann

package wjf;
import java.util.Scanner;
public class wjf1{
	public static  void main(String[] args){   
		//創建鳥類數組
	    String[]aves=new String[]{"白鷺","黃鸝","鸚鵡","烏鴉","喜鵲","布谷鳥","斑鳩","百靈鳥"};
	    int index=0;
		  System.out.println("我的花園裏有很多鳥,大約包括:"); 
	    while(index<aves.length){
		  System.out.println(aves[index++]);
		}
	}
}

  

實例20 使用while循環語句與自增運算符循環遍歷數組