How to take inputs from a user if the number of elements is not known

i tried it taking from a string and splitting it using the split function in java and than converting it in an array but i thing the array size is overflowed
can anyone suggest me a way to counter this problem so that i can take more elements than the integer limit.

— do endless reading, use a try catch of null pointer exception (when it ends)

try {
while (true) {
// read file and your algorithm
} catch (NullPointerException e) {

1 Like