3
A
回答
8
運行 - >運行配置 - >參數(這是右邊的第二個選項卡) - >程序參數
2
在程序中添加此行接受來自控制檯用戶的輸入:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
然後添加in.readLine()旁邊的任何變量您想接受運行時輸入。比方說,你要計數變量初始化爲值1,那麼,它應該寫成
int count = in.readLine();
值1,應在控制檯運行程序
0
這裏後輸入是一個辦法在Eclips中輸入用戶輸入。
import java.util.Scanner; // enter the before the start of any class
// declare the class here
// this is an example of how to use the Scanner in a method
Public static void Username();{
Scanner Input = new scanner (System.in);
String username// declaring the username variable
Scanner un = new Scanner(System.in); // un is just a random variable you can choose any other variable name if you want
System.out.println("Enter Your Username");
username = un.next();
System.out.println("The username you entered is : " + username);}
但是,如果你想在這裏取一個整數或雙精度作爲輸入,你怎麼做。 我只是想舉一個int輸入的例子,你只需用double替換int即可。
import java.util.Scanner;
// Declare the class here
// this is an example of how to use the Scanner in a method for an integer input by user
Public static void booksRead();{
Scanner Input = new scanner (System.in);
int books // declaring the books variable
Scanner br = new Scanner(System.in); // br is just a random variable you can choose any other variable name if you want
System.out.println("Enter how many books have you read: ");
books = br.next();
System.out.println("The number of books you have read is : " + books);}
0
這將打印由用戶輸入的號碼:
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter a number: ");
int n = reader.nextInt(); // Scans the next token of the input as an int.
//once finished
System.out.println(n);
reader.close();
}
相關問題
- 1. 如何接受用戶輸入php
- 2. 接受用戶輸入perl
- 3. 接受用戶的輸入
- 4. 在oracle 10g中,如何接受循環中的用戶輸入?
- 5. 如何在Python中以用戶輸入接受圖像
- 6. 如何在Python中的腳本之後接受用戶輸入?
- 7. 如何在安裝過程中接受用戶輸入
- 8. haskell方式接受用戶輸入的用戶輸入次數?
- 9. 使用宏接受用戶輸入
- 10. 使用scanf接受用戶輸入
- 11. 如何接受用戶輸入並插入http獲取請求?
- 12. 在nodejs中接受輸入
- 13. 通過EditText接受用戶輸入
- 14. execvp()不接受用戶輸入
- 15. Python不會接受用戶輸入
- 16. Xcode不接受用戶輸入!
- 17. Editext不接受用戶輸入的值
- 18. 用戶輸入接受str和int(python)
- 19. 登錄時接受用戶輸入
- 20. 接受來自Activity的用戶輸入
- 21. 接受用戶輸入的變量
- 22. PHP文件接受用戶輸入
- 23. 如何在Inno Setup中使用多行文本框接受用戶輸入?
- 24. 如何在Python中的多維列表中接受用戶輸入?
- 25. 如何接受複雜數字的用戶輸入
- 26. 如何使Html.TextBoxFor DateTime接受用戶輸入dd.MM.yy
- 27. 如何接受來自C++用戶的二進制輸入?
- 28. 如何接受用戶輸入的矢量大小?
- 29. powershell用戶輸入驗證不接受有效輸入
- 30. 如何在Eclipse RCP應用程序中使用用戶輸入?
以上解決方案只是在運行時接受用戶輸入的另一種方式,是不是上面貼的問題的答案。請注意 – 2012-07-20 11:19:23