Here you can find the source of sub(String[] a, String[] b)
public static String[] sub(String[] a, String[] b)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**/*from w w w . j a v a 2 s. c o m*/ * subtract b from a */ public static String[] sub(String[] a, String[] b) { // really inefficient... TreeSet<String> s = new TreeSet<>(Arrays.asList(a)); s.removeAll(Arrays.asList(b)); if (s.size() != a.length) { //System.out.println("sub: " + Arrays.toString(a) + " - " + Arrays.toString(b) + " = " + s); return s.toArray(new String[s.size()]); } else { return a; } } }