Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se). * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0-standalone.html ******************************************************************************/ import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <T> List<T> conjunction(Collection<T> c1, Collection<T> c2) { if (c1 == null || c2 == null) { return null; } else { List<T> result = new ArrayList<T>(c1.size()); for (T o : c1) { if (c2.contains(o)) { result.add(o); } } return result; } } }