Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {

        ArrayList<String> arrlist = new ArrayList<String>(5);

        arrlist.add("G");
        arrlist.add("E");
        arrlist.add("F");
        arrlist.add("M");
        arrlist.add("E");
        arrlist.add("from java2s.com");

        System.out.println("Size of list: " + arrlist.size());

        System.out.println(arrlist);

        // Retrieving the index of last occurrence of element "E"
        int retval = arrlist.lastIndexOf("E");
        System.out.println("The last occurrence of E is at index " + retval);

    }
}