Here you can find the source of difference(Vector a, Vector b)
public static Vector difference(Vector a, Vector b)
//package com.java2s; import java.util.*; public class Main { public static Vector difference(Vector a, Vector b) { Vector r = new Vector(); for (int i = 0; i < a.size(); i++) { boolean inB = false; for (int j = 0; j < b.size(); j++) { if (a.elementAt(i).equals(b.elementAt(j))) { inB = true;//from w ww . j a v a 2 s . c om break; } } if (!inB) r.add(a.elementAt(i)); } return r; } }