Nisreen Rose Nisreen Rose - 1 year ago 114
Java Question

How to reverse ArrayList input?

I am working on my application Reflects Input


When user enters 1, 2, 3. ArrayList will reverses and prints 3,2,1

How i can do this with ArrayList?

INPUT 1, 2, 3

OUTPUT 3, 2, 1

Answer Source

You can try:

ArrayList<Object> objects= new ArrayList<Object>(objects);

Or you can add them at front:

objects.add(0, yourObject);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download