public class test {

    public static void main(String[] args) {
        int [] list = {1,2,3,4,5,8};

        for(int a :list) {                                          //表示從list陣列中,從陣列第一個值取值取到最後一個值
             System.out.println(a + "-888");
        }

      // ------------------ 等於以下寫法 ------------------


        for(int b = 0;b <= list.length - 1;b++){
             System.out.println(list[b] + "-777");

        }

    }
}

 

結果 :

1-888
2-888
3-888
4-888
5-888
8-888
1-777
2-777
3-777
4-777
5-777
8-777

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 minotomato 的頭像
    minotomato

    飛。霏

    minotomato 發表在 痞客邦 留言(0) 人氣()