Board logo

標題: 資料輸入 (一) [打印本頁]

作者: 陳弘修    時間: 2020-10-17 10:03     標題: 資料輸入 (一)

運用套件 java.io 下的 Console 類別, 作字串輸入的練習.

  1. import java.io.Console;
  2. public class Ch05
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1,str2;
  7.          Console c=System.console();
  8.          System.out.print("輸入字串一: ");
  9.          str1=c.readLine();
  10.          System.out.println("字串一: "+str1);
  11.          System.out.print("輸入字串二: ");
  12.          str2=c.readLine();
  13.          System.out.println("字串二: "+str2);
  14.     }
  15. }
複製代碼
  1. import java.io.Console;
  2. public class Ch03
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1, str2;
  7.          Console c=System.console();

  8.          str1=c.readLine("輸入字串1: ");
  9.          str2=c.readLine("輸入字串2: ");

  10.          System.out.println("字串1: "+str1);
  11.          System.out.println("字串2: "+str2);
  12.     }
  13. }
複製代碼

作者: 王銘鴻    時間: 2020-10-17 11:23

  1. import java.io.Console;
  2. public class Ch05
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1,str2;
  7.          Console c=System.console();
  8.          System.out.print("輸入字串一: ");
  9.          str1=c.readLine();
  10.          System.out.println("字串一: "+str1);
  11.          System.out.print("輸入字串二: ");
  12.          str2=c.readLine();
  13.          System.out.println("字串2: "+str2);
  14.     }
  15. }
複製代碼

作者: 林羿丞    時間: 2020-10-17 11:24

  1. import java.io.Console;
  2.   public class Ch666
  3.   {
  4.     public static void main(String args[])
  5.     {
  6.          String str1, str2;
  7.          Console c=System.console();

  8.          str1=c.readLine("輸入字串1: ");
  9.          str2=c.readLine("輸入字串2: ");

  10.          System.out.println("字串1: "+str1);
  11.          System.out.println("字串2: "+str2);
  12.     }
  13. }
複製代碼

作者: 李穎俊    時間: 2020-10-17 11:32

本帖最後由 李穎俊 於 2020-10-17 11:34 編輯
  1. import java.io.Console;
  2. public class Ch777
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1,str2;
  7.          Console c=System.console();
  8.          System.out.print("輸入字串一: ");
  9.          str1=c.readLine();
  10.          System.out.println("字串一: "+str1);
  11.          System.out.print("輸入字串二: ");
  12.          str2=c.readLine();
  13.          System.out.println("字串二: "+str2);
  14.     }
  15. }
複製代碼
  1. import java.io.Console;
  2. public class Ch666
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1, str2;
  7.          Console c=System.console();

  8.          str1=c.readLine("輸入字串一: ");
  9.          str2=c.readLine("輸入字串二: ");

  10.          System.out.println("字串1: "+str1);
  11.          System.out.println("字串2: "+str2);
  12.     }
  13. }
複製代碼

作者: 龔品誠    時間: 2020-10-17 11:59

  1. import java.io.Console;
  2. public class OwO
  3. {
  4.     public static void main(String args[])
  5.     {
  6.          String str1, str2;
  7.          Console c=System.console();

  8.          str1=c.readLine("輸入字串1: ");
  9.          str2=c.readLine("輸入字串2: ");

  10.          System.out.println("字串1: "+str1);
  11.          System.out.println("字串2: "+str2);
  12.     }
  13. }
複製代碼

作者: 張淯祺    時間: 2020-10-24 09:51

  1. import java.io.Console;
  2. public class Ch05
  3. {

  4.     public static void main(String args[])
  5.     {
  6.          String str1,str2;
  7.          Console c=System.console();
  8.          System.out.print("輸入字串一:");
  9.          str1=c.readLine();
  10.          System.out.println("字串一: "+str1);
  11.          System.out.print("輸入字串2:");
  12.          str2=c.readLine();
  13.          System.out.println("字串2: "+str2);
  14.     }
  15. }
複製代碼

作者: 朱閎聿    時間: 2020-10-24 09:52

  1. import java.io.Console;
  2. public class Ch05
  3. {
  4.     public static void main(String args[])
  5.     {
  6.       String str1,str2;
  7.       Console c=System.console();
  8.       System.out.print("輸入字串一: ");
  9.       str1=c.readLine();
  10.       System.out.println("字串一: "+str1);
  11.       System.out.print("輸入字串二: ");
  12.       str2=c.readLine();
  13.       System.out.println("字串二: "+str2);
  14.     }
  15. }
複製代碼

作者: 黃柏智    時間: 2020-11-5 19:01

  1. import java.io.Console;
  2. public class Ch05
  3. {
  4.     public static void main(String args[])
  5.     {
  6.      String str1,str2;
  7.      Console c= System.console();
  8.      System.out.println("輸入字串一");
  9.      str1=c.readLine();
  10.      System.out.println("字串一為"+str1);
  11.      System.out.println("輸入字串");
  12.      str2=c.readLine();
  13.      System.out.println("字串一二為"+str2);
  14.     }
  15. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2