[問題] 新手一問 關於語法

看板java作者 (駭客技術去哪學?)時間17年前 (2009/03/04 23:48), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
1. import java.util.Scanner; public class New { public static void main(String args[ ]) { Scanner scanner = new Scanner(System.in); System.out.printf("Hello!!") ; System.out.println(); System.out.printf("enter a number:"); System.out.printf("Oh! I get a number %d!!\n", scanner.nextInt()); System.out.println("You are ?"); System.out.printf("Hello, %s\n", scanner.next()); } } /* JAVA中似乎再讓使用者輸入前不需宣告變數及形態,那如此他要如何知道我 輸入多少變數? 如:在enter a number:後面我輸入整數玩在輸入字元字串在輸入浮點數 ...,他要如何記憶??如果我輸入兩次整數那下一行輸出結果要輸出哪個呢?*/ 2. import java.io.*; public class New { public static void main(String[] args) throws IOException { BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); /* 上面這行是類似C的別名嗎?還是?? */ System.out.print("請輸入一列文字: "); String text = buf.readLine(); /* 看不懂 ~"~ */ System.out.println("您輸入的文字: " + text); /*位什麼是+?? */ } } 抱歉我是新手 沒書 只有在網路上自學 但是他的範例中 很多都沒講原因 跟做註解 所以學起來霧煞煞 煩請高手不吝解析 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.91.18
文章代碼(AID): #19hgBezQ (java)
文章代碼(AID): #19hgBezQ (java)