Skip to content
Advertisement

ArrayList input java

Im looking at the problem:

Write a program which reads a sequence of integers and displays them in ascending order.

Im creating an ArrayList (which I am new to) and I want to populate with integers input from the command line. With an array I could use a for loop with

JavaScript

but with an ArrayList of unbounded size Im not sure how to process the input?

EDIT:

JavaScript

Advertisement

Answer

The idea with using ArrayList is to avoid the deterministic iteration counts. Try something like this:

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