在下面的代碼,userInput是不一樣的決定input.nextInt() <= 100.
如何從InputStream中查看nextInt?
`while (input.nextInt() <= 100)
{
System.out.println("larger than 100 please");
input.nextLine();
}
userInput = input.nextInt();`
我知道有類似下面的其他方式的價值,
do { userInput = input.nextInt(); }while (input.nextInt() <= 100)
是否有可能爲vaiable userInput到讀取與前一個邏輯決策中使用的值相同的值?
你有沒有考慮存儲在一個變量? –
我們無法知道變量'input'的類型是什麼。你能否包含更多的上下文代碼?至少是'input'的聲明和實例化? –