LoginSignup
3
2

More than 5 years have passed since last update.

Javaのfor文

Last updated at Posted at 2018-07-20

for文というのは繰り返しの構文です。for文を使いこなせれば、表やたくさんの行のある大きなデータも取り扱うことができるようになります。

書き方
for (初期化式; 条件式; 更新式) {
     処理内容;
}

サンプルコード:

ForSample.java
public class ForSample {

   public static void main(String args[]) {

      for(int x = 10; x < 20; x = x + 1) {

         //xの値を表示
         System.out.println("xの値 : " + x );

      }
   }
}
結果
xの値 : 10
xの値 : 11
xの値 : 12
xの値 : 13
xの値 : 14
xの値 : 15
xの値 : 16
xの値 : 17
xの値 : 18
xの値 : 19
3
2
1

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
3
2