[Solved] Exception in thread “main” java.lang.StringIndexOutOfBoundsException: String index out of range: 0 [closed]


nextDouble() leaves the newline in the input stream, so when you then call

nextLine().charAt(0)

the result of nextLine() is an empty string. Remove the newline from the stream, or use next(), as you did above.

5

solved Exception in thread “main” java.lang.StringIndexOutOfBoundsException: String index out of range: 0 [closed]