Board logo

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

作者: tonyh    時間: 2018-9-17 19:23     標題: 資料輸入 (一)

本帖最後由 tonyh 於 2019-6-30 13:28 編輯

運用套件 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. }
複製代碼

作者: 黃宇綸    時間: 2018-9-17 20:13

  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. }
複製代碼

作者: 洪翊展    時間: 2018-9-17 20:14

  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. }
複製代碼

作者: 洪翊庭    時間: 2018-9-17 20:20

  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. }
複製代碼

作者: 曾堂桂    時間: 2018-9-17 20:25

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

作者: 啓銓    時間: 2018-9-17 20:26

本帖最後由 啓銓 於 2018-9-17 20:35 編輯
  1. import java.io.Console;
  2. public class Ch01
  3. {
  4.     public static void main (String args[])
  5.     {
  6.       String str, str2;
  7.       Console c= System.console();
  8.       str=c.readLine("輸入字串1:");
  9.       str2=c.readLine("輸入字串2:");
  10.       System.out.println("你剛輸入了:"+str);
  11.       System.out.println("你剛輸入了:"+str2);
  12.     }
  13. }
複製代碼

作者: 黃宇瑄    時間: 2018-9-17 20:28

  1. import java.io.Console;
  2. public class Ch02
  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. }
複製代碼

作者: 李沛昂    時間: 2018-9-17 20:29

  1. import java.io.Console;
  2. public class Ch03
  3. {
  4.     public static void main(String pig[])
  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. }
複製代碼





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