Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Collections;
import java.util.List;
import java.util.Vector;

public class Main {
    public static void main(String[] args) {
        // create vector
        List<String> vector = new Vector<String>();

        // populate the vector
        vector.add("R");
        vector.add("B");
        vector.add("R");
        vector.add("java2s.com");

        System.out.println("Initial values are :" + vector);

        Collections.replaceAll(vector, "R", "java2s.com");

        System.out.println("Value after replace :" + vector);
    }
}