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> arrlist = new ArrayList<String>();

        // populate the list
        arrlist.add("A");
        arrlist.add("B");
        arrlist.add("from java2s.com");

        System.out.println("List elements before fill: " + arrlist);

        // fill the list
        Collections.fill(arrlist, "java2s.com");

        System.out.println("List elements after fill: " + arrlist);
    }
}