Skip to content
Advertisement

Java Array List – Facing issue while taking values from user, but unknowingly program terminating

I am trying to take values from user in ArrayList, I can take input for the size of ArrayList, But, when I am trying to add elements, the program is being terminating. Here is my code

JavaScript

Advertisement

Answer

You must use .readLine() also inside the loop:

JavaScript

Running result:

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