/** * Created by Yuhui on 2017/7/11 0011.
* * Import Java.util.HashSet;
Import Java.util.Set; public class Testset {public static void main (string[] args) {set<string> result = new Hashset<st
Ring> ();
set<string> Set1 = new Hashset<string> () {Add ("Glory of Kings");
Add ("League of Heroes");
Add ("Through the FireWire");
Add ("Dungeon and Warrior");
}
};
set<string> Set2 = new Hashset<string> () {Add ("Glory of Kings");
Add ("Dungeon and Warrior");
Add ("World of Warcraft");
}
};
Result.clear ();
Result.addall (SET1);
Result.retainall (Set2);
System.out.println ("intersection:" + result);
Result.clear ();
Result.addall (SET1);
Result.removeall (Set2);
SYSTEM.OUT.PRINTLN ("Difference set:" + result);
Result.clear ();
Result.addall (SET1);
Result.addall (Set2); SystEm.out.println ("and set:" + result);
}
}
The results are as follows:
Intersection: [King Glory, Dungeon and Warrior]
Difference set: [League of Heroes, through the FireWire]
and set: [King Glory, League of Heroes, World of Warcraft, Dungeons and Warriors, through the FireWire]
If you like the blog I wrote, after reading the harvest is very big, may wish to small sponsor me, let me have the power to continue to write High-quality blog, thank you for your appreciation ...