1: 2: 3: 4: 5: 6: 7: 8: |
class Rei7_1{
public static void main(String[] args){
int i;
for(i=0; i<10 ; i++){
System.out.println("連続で出力");
}
}
}
|
1: 2: 3: 4: 5: 6: 7: 8: 9: |
class Rei7_2{
public static void main(String[] args){
int i = 0;
while(i<10 ){
System.out.println("連続で出力");
i++;
}
}
}
|
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: |
import java.io.*;
class Rei7_3{
public static void main(String[] args) throws IOException{
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
System.out.print("-1を入力するまで繰り返すですよ:");
String str = br.readLine();
int a = Integer.parseInt(str);
//-1でないとき繰り返す
//-1を入力したときは終了する
while(a != -1){
System.out.print("-1を入力するまで繰り返すですよ:");
str = br.readLine();
a = Integer.parseInt(str);
}
}
}
|
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: |
import java.io.*;
class Rei7_4{
public static void main(String[] args) throws IOException{
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
String str;
int a;
//-1でないとき繰り返す
//-1を入力したときは終了する
do{
System.out.print("-1を入力するまで繰り返すですよ:");
str = br.readLine();
a = Integer.parseInt(str);
}while(a != -1);
}
}
|