Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        ArrayList<String> arrayList = new ArrayList<String>();

        arrayList.add("A");
        arrayList.add("B");
        arrayList.add("A");
        arrayList.add("C");
        arrayList.add("D");

        System.out.println(arrayList);

        Collections.replaceAll(arrayList, "A", "Replace All");

        System.out.println(arrayList);
    }
}
/*
[A, B, A, C, D]
[Replace All, B, Replace All, C, D]
*/