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("from java2s.com");

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

        System.out.println(arrlist);

        // retrieving the index of element "E"
        int retval = arrlist.indexOf("E");
        System.out.println("The element E is at index " + retval);
    }
}