我一直想知道是否有任何方法可以重用字符串,如:
import java.io.Console;
public class input {
public static void main (String[] args) {
Console console = System.console();
String input = console.readLine("Type username: "); //user input
// name code
// clear string
String input = console.readLine("Hello, what would you like to do: ");
// other code
}
}
Run Code Online (Sandbox Code Playgroud)
通过清除字符串//clear string,所以如果你有一个循环的用户输入,如果一个东西没有出现,它不会中断.
| 归档时间: |
|
| 查看次数: |
656 次 |
| 最近记录: |