I'm trying to add scanner inputs into an ArrayList
, but I can't exit out the loop after I have entered the inputs. How can I exit this loop after I'm done entering inputs?
ArrayList<String> inputs = new ArrayList<>();
int i = 0;
while(scan.hasNext()){//while there is an hasNext
inputs.add(scan.next());// add to the inputs array of queue
i++;
}scan.close()
;