-1
충돌하고, 즉, catch
NumberFormatException
그 프로그램 수익률을 작동하고 사용자에게 다시 메시지 표시하지 않는 경우.있는 Integer.parseInt()는 내가 <code>int</code>에 <code>String</code> 변환 <code>Integer.parseInt()</code>를 사용하려고 Java 프로그램
그러나 String
값을 입력하면 재발신 대신 프로그램이 정지됩니다.
keepLooping = true;
while(keepLooping) {
String unconvertedString = "";
int convertedInt = 0;
try {
System.out.print("Enter a string to be parsed into an integer: ");
unconvertedString = userInput.next();
convertedInt = Integer.parseInt(unconvertedString);
keepLooping = false;
}
catch (NumberFormatException e) {
userInput.next();
}
}
그래서 int를 제공하면 올바르게 작동합니까? userInput은 정확히 무엇입니까? – Reisclef
'next()'는 무엇이라고 생각하십니까? –
'userInput'이란 무엇입니까? 'userInput.next()'의 기능은 무엇입니까? – YoungSpice