Here you can find the source of mergeVectors(Vector v1, Vector v2)
Parameter | Description |
---|---|
v1 | Vector1 |
v2 | Vector2 |
public static Vector mergeVectors(Vector v1, Vector v2)
//package com.java2s; /* IBS Copyright/Security Notice *************************************** * * BAP Property of IBS AB//from w ww .java2s. co m * (C) Copyright IBS AB 2001 * All rights reserved. * Use, duplication, or disclosure restricted * by license agreement with IBS AB. * * Licensed Materials - Property of IBS AB * * End IBS Copyright/Security Notice **********************************/ import java.util.*; public class Main { /** * Return a vector with entries existing in both vectors * * @param v1 Vector1 * @param v2 Vector2 * @return Vector or null if vector v1 or v2 not passed */ public static Vector mergeVectors(Vector v1, Vector v2) { if (v1 == null || v2 == null) { return null; } Vector v = new Vector(); if (v1.isEmpty() || v2.isEmpty()) { return v; } int size = v1.size(); Object obj = null; for (int i = 0; i < size; i++) { obj = v1.get(i); if (v2.contains(obj)) { v.add(obj); } } return v; } }