ArrayList: retainAll(Collection c) : ArrayList : java.util : Java by API examples (example source code) Organized by topic

Java by API
C++
PHP
Java by API Home »  java.util   » [  ArrayList  ]   
 



ArrayList: retainAll(Collection c)

/*
 Output:


true
[2nd, 3rd, 2nd, 3rd]


 * */

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

public class MainClass {
  public static void main(String args[]) {
    String orig[] "1st""2nd""3rd""4th""5th""1st""2nd""3rd",
        "4th""5th" };
    String act[] "2nd""3rd""6th" };
    List origList = new ArrayList(Arrays.asList(orig));
    List actList = Arrays.asList(act);

    System.out.println(origList.retainAll(actList));
    System.out.println(origList);
  }
}
           
       
Related examples in the same category
1.  new ArrayList < E > ()
2.  ArrayList: add(E o)
3.  ArrayList: add(int index, E element)
4.  ArrayList: contains(Object elem)
5.  ArrayList: ensureCapacity(int minCapacity)
6.  ArrayList: indexOf(Object elem)
7.  ArrayList: iterator()
8.  ArrayList: listIterator()
9.  ArrayList: remove(int index)
10.  ArrayList: remove(Object o)
11.  ArrayList: size()
12.  AbstractList: subList(int fromIndex, int toIndex)
13.  ArrayList: toArray(T[] a)
14.  ArrayList: trimToSize()
15.  for each loop for ArrayList
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.