の違いだから私は2セット持っている場合:取得二組
Set<int> test1 = new HashSet<Integer>();
test1.add(1);
test1.add(2);
test1.add(3);
Set<int> test2 = new HashSet<Integer>();
test2.add(1);
test2.add(2);
test2.add(3);
test2.add(4);
test2.add(5);
それらを比較してわずか4と5のセットが返さを持ってする方法はありますか?
可能な複製http://stackoverflow.com/questions/8064570/what-is-the-best-way-get-the-symmetric-difference-between-two-sets-in-java –
これは可能ではありません正確な重複:対称の差異と差異は同じではありません。 –
'test1'に' 6'が含まれていれば、答えは4,5,6でしょうか?あなたが対称的な差異をしたいのですか?http://en.wikipedia.org/wiki/Symmetric_difference –