アットウィキロゴ

標準出力

Stream

  1. import java.io.*;
  2.  
  3. class sample10{
  4. public static void main(String[] args) throws IOException{
  5.  
  6.  
  7. int a = 0;
  8. while(a != 99){
  9. System.out.printf("a=");
  10. String str = br.readLine();
  11. System.out.printf(">>>a=%s\n", str);
  12. a = Integer.parseInt(str);
  13. }
  14.  
  15. }
  16. }
  17.  

標準入力

Scanner

  1. import java.util.*;
  2.  
  3. class sample11{
  4. public static void main(String[] args){
  5.  
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. int a = 0;
  9. while(a != 99){
  10. System.out.print("a=");
  11. a = scan.nextInt();
  12. System.out.printf(">>>a=%d\n", a);
  13. }
  14.  
  15. }
  16. }
  17.  




最終更新:2012年09月02日 10:29