多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 简介 特点:无序,无重复元素 # 命令行 ![](https://box.kancloud.cn/b0df61fdc0372fabc056db0f0a38b1b1_710x528.png) ![](https://box.kancloud.cn/0947f962be35e8a110270cbf0cfe0ebc_598x413.png) ![](https://box.kancloud.cn/d912fd33b4d3819dc3fb6cb521272b04_661x724.png) ![](https://box.kancloud.cn/a75913d7bd8f046d9ddf9b4f7758832b_182x129.png) # 代码 ~~~ Jedis jedis = init(); //有的话返回0,没有的话添加成功是返回非0 Long a1 = jedis.sadd("friends:1", "dandan", "lulu", "lili"); Long a2 = jedis.sadd("friends:2", "laowang", "laodu", "laoli", "lili"); //判断一个成员是否属于指定的集合 Boolean isornot = jedis.sismember("friends:1","laowang"); System.out.println(isornot); //求2个集合的差并交集 Set<String> sdiff = jedis.sdiff("friends:1", "friends:2"); Set<String> sunion = jedis.sunion("friends:1", "friends:2"); Set<String> sinter = jedis.sinter("friends:1", "friends:2"); //打印结果 System.out.println("---差集---"); for (String sd: sdiff) { System.out.println(sd); } System.out.println("---并集---"); for (String su: sunion) { System.out.println(su); } System.out.println("---交集---"); for (String si: sinter) { System.out.println(si); } ~~~