Skip to content
Advertisement

Program is having issues with inputting arrays

The output for the following code is: Please enter your words: hello, keshav, bob, doan kehsavbob Exception in thread “main” java.lang.NumberFormatException: For input string: “kehsavbob” at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) at java.base/java.lang.Integer.parseInt(Integer.java:668) at java.base/java.lang.Integer.parseInt(Integer.java:786) at MyClass.main(MyClass.java:101)

JavaScript

}

Advertisement

Answer

You are trying to parse an integer from a word, which won’t work.

Replace:

JavaScript

with:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement