import java.util.ArrayList;
import java.util.Collections;
import static java.lang.System.out;
class ReverseList
{
public static void main(String...alt)
{
ArrayList al=new ArrayList();
al.add(20);
al.add(1);
al.add(12);
al.add(35);
al.add(16);
al.add(2);
out.println("Before Reverse : "+al);
Collections.reverse(al);
out.println("After Reverse : "+al);
}
}
import java.util.Collections;
import static java.lang.System.out;
class ReverseList
{
public static void main(String...alt)
{
ArrayList al=new ArrayList();
al.add(20);
al.add(1);
al.add(12);
al.add(35);
al.add(16);
al.add(2);
out.println("Before Reverse : "+al);
Collections.reverse(al);
out.println("After Reverse : "+al);
}
}
0 Comment to "Java Program to insert element in List and print in reverse order."
Post a Comment