2012年5月31日 星期四

Java Basic(28)-Creating an Array Table


class apples{
public static void main(String args[]){
System.out.println("Index\tValue");
int bucky[]={32,12,18,54,2}; 5個變量在這個陣列

for(int counter=0;counter<bucky.length;counter++){
System.out.println(counter + "\t" + bucky[counter]);
}
}
}



.length 是多少變量這個陣列中,在這種情況下,5
\t 表示 tab

Program將運行這樣的:
Index Value
0 32
1 12
2 18
3 54
4 2

沒有留言:

張貼留言