MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

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

class MainClass {
    public static void main(String[] args) {
        String[] coins = { "A", "B", "C", "D", "E" };

        List src = new LinkedList();
        for (int i = 0; i < coins.length; i++)
            src.add(coins[i]);

        List dst = new ArrayList();
        for (int i = 0; i < coins.length; i++)
            dst.add("");

        Collections.copy(dst, src);

        ListIterator liter = dst.listIterator();

        while (liter.hasNext())
            System.out.println(liter.next());

        Collections.fill(src, "no coins");

        liter = src.listIterator();

        while (liter.hasNext())
            System.out.println(liter.next());
    }
}