PIYUJIN / Exercise-Memo-Program

This is Exercise Memo Program that can record exercise information.
0 stars 0 forks source link

scanner error #2

Open PIYUJIN opened 11 months ago

PIYUJIN commented 11 months ago

scanner가 인식하는 변수형과 다른 타입을 입력하는 경우 오류 발생

해결방안

try {
    val inputNumber = scanner.nextInt()
} catch(e: Exception) {
    // 정수형 변수를 입력받는 함수 이후 한번 엔터(공백) 읽어오기
    scanner.nextLine()
}