Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static void setByIndex() {
        List<Integer> l = new ArrayList<Integer>();
        l.add(1);
        l.add(2);
        l.add(3);
        l.add(4);
        for (int i = 0; i < 4; i++) {
            System.out.println(l.get(0));
            l.remove(0);
        }
    }
}