Nisreen Rose Nisreen Rose - 4 months ago 36
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


You can try:

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

Or you can add them at front:

objects.add(0, yourObject);