Sunday, 10 May 2015

How to Remove List From Arraylist

 We can remove  all element of list from arraylist using removeAll().

import java.util.ArrayList;
import java.util.List;

public class RemoveList {

    public static void main(String[] args) {
        ArrayList<String> arr = new ArrayList<String>();
        // add element in arraylist
        // print arraylist
        System.out.println(" berfore remove arrayList is = " + arr);
        List<String> brr = new ArrayList<String>();
         * Removes from this list all of its elements that are
           contained in the specified collection.
        System.out.println("after remove arraylist is = "+arr);


 berfore remove arrayList is = [c, php, html, java]

 after remove arraylist is = [c, html]

Related Posts: 


Storing Java Object In ArrayList

No comments:

Post a Comment