Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // create array list object
        List<String> arrlst = new ArrayList<String>();

        // populate the list
        arrlst.add("A");
        arrlst.add("B");
        arrlst.add("C");
        arrlst.add("D");
        arrlst.add("from java2s.com");

        System.out.println("The initial list is :" + arrlst);

        // reverse the list
        Collections.reverse(arrlst);

        System.out.println("The Reverse List is :" + arrlst);
    }
}