Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> symmetryDifference(List<T> a, List<T> b) { List<T> result = difference(a, b); result.addAll(difference(b, a)); return result; } public static <T> List<T> difference(List<T> a, List<T> b) { List<T> result = new ArrayList<>(); for (T at : a) { boolean has = false; for (T bt : b) { if (at.equals(bt)) { has = true; break; } } if (!has) { result.add(at); } } return result; } }