Here you can find the source of intersect(Collection container, Collection contained)
Parameter | Description |
---|---|
container | a collection |
contained | another collection |
public static Collection intersect(Collection container, Collection contained)
//package com.java2s; // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: import java.util.*; public class Main { /**/*from w w w. jav a 2 s.c o m*/ * * @param container a collection * @param contained another collection * @return an intersection */ public static Collection intersect(Collection container, Collection contained) { Collection copy = new ArrayList(container); copy.retainAll(contained); return copy; } }