Replacing all of the elements of the specified list with the specified element.



package collection.demos;


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


public class FillingElementsInList {
    public static void main(String[] args) {
        ArrayList<String> activities=new ArrayList<String>();
        activities.add("analysis");
        activities.add("design");
        activities.add("development");
        activities.add("testing");
        activities.add("support");
        System.out.println("List : "+activities);
        Collections.fill(activities, "none");
        System.out.println("List after Swapped : "+activities);
    }

}

No comments:

Popular Posts