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[]) {

        // create an empty array list
        ArrayList<StringBuilder> arrlist1 = new ArrayList<StringBuilder>();

        // use add for new value
        arrlist1.add(new StringBuilder("from java2s.com"));

        // using clone to affect the objects pointed to by the references.
        ArrayList arrlist2 = (ArrayList) arrlist1.clone();

        // appending the string
        StringBuilder strbuilder = arrlist1.get(0);
        strbuilder.append("tutorials");

        System.out.println(arrlist1);

        System.out.println(arrlist2);
    }
}