概要
Javaで「while文を使った繰り返し処理」の動作を確認してみました。
以下のページを参考にしました。
実装
以下のファイルを作成しました。
JSample6_1.java
class JSample6_1{
public static void main(String[] args){
int num = 1;
while (num < 100){
System.out.println("num = " + num);
num *= 2;
}
}
}
以下のコマンドを実行しました。
$ javac JSample6_1.java
$ java JSample6_1
num = 1
num = 2
num = 4
num = 8
num = 16
num = 32
num = 64
まとめ
何かの役に立てばと。