Given below the sample code :
import java.util.*;
public class reverseLIst {
public static void main(String[] args) {
ArrayList<String> mylist = new ArrayList<String>();
mylist.add("1");
mylist.add("2");
mylist.add("3");
System.out.println("Before reversing array list:"+mylist);
Collections.reverse(mylist);
System.out.println("After reversing array list:"+mylist);
}
}
What will be the output of the above code ?
1. Compilation error
2. No output
3. Before reversing array list:[1, 2, 3]
After reversing array list:[3, 2, 1]
4. Before reversing array list:[1, 2, 3]
After reversing array list:[1, 2, 3]
(3)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.