LoginSignup
0
0

More than 5 years have passed since last update.

JAVA 拡張for文 for(要素の型 任意の変数名:配列変数名) { ・・・}

Last updated at Posted at 2015-11-06

拡張for文-----------------------------------------------------------------------------------
for(要素の型 任意の変数名:配列変数名) {

}
------------------------------------------------------------------------------------------------

拡張for文とは、配列の要素を1つずつ取り出すループを簡単に書くために導入された新しいfor文の文法です。

■Test02.java


public class Test02 {
    public static void main(String[] args) {
        int[] score = { 20, 30, 40, 50, 80 };
        for (int value : score) {
            System.out.println(value);
        }
    }

}

■実行結果
20
30
40
50
80

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0