1. <i id='qkTND'><tr id='qkTND'><dt id='qkTND'><q id='qkTND'><span id='qkTND'><b id='qkTND'><form id='qkTND'><ins id='qkTND'></ins><ul id='qkTND'></ul><sub id='qkTND'></sub></form><legend id='qkTND'></legend><bdo id='qkTND'><pre id='qkTND'><center id='qkTND'></center></pre></bdo></b><th id='qkTND'></th></span></q></dt></tr></i><div id='qkTND'><tfoot id='qkTND'></tfoot><dl id='qkTND'><fieldset id='qkTND'></fieldset></dl></div>

        <small id='qkTND'></small><noframes id='qkTND'>

      2. <tfoot id='qkTND'></tfoot>

        • <bdo id='qkTND'></bdo><ul id='qkTND'></ul>
        <legend id='qkTND'><style id='qkTND'><dir id='qkTND'><q id='qkTND'></q></dir></style></legend>
      3. 获取两组之间的差异

        Getting the difference between two sets(获取两组之间的差异)

          <small id='VAc4C'></small><noframes id='VAc4C'>

            <legend id='VAc4C'><style id='VAc4C'><dir id='VAc4C'><q id='VAc4C'></q></dir></style></legend>

                <bdo id='VAc4C'></bdo><ul id='VAc4C'></ul>
                <i id='VAc4C'><tr id='VAc4C'><dt id='VAc4C'><q id='VAc4C'><span id='VAc4C'><b id='VAc4C'><form id='VAc4C'><ins id='VAc4C'></ins><ul id='VAc4C'></ul><sub id='VAc4C'></sub></form><legend id='VAc4C'></legend><bdo id='VAc4C'><pre id='VAc4C'><center id='VAc4C'></center></pre></bdo></b><th id='VAc4C'></th></span></q></dt></tr></i><div id='VAc4C'><tfoot id='VAc4C'></tfoot><dl id='VAc4C'><fieldset id='VAc4C'></fieldset></dl></div>
                <tfoot id='VAc4C'></tfoot>

                  <tbody id='VAc4C'></tbody>
                • 本文介绍了获取两组之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以如果我有两套:

                  Set<Integer> test1 = new HashSet<Integer>();
                  test1.add(1);
                  test1.add(2);
                  test1.add(3);
                  
                  Set<Integer> test2 = new HashSet<Integer>();
                  test2.add(1);
                  test2.add(2);
                  test2.add(3);
                  test2.add(4);
                  test2.add(5);
                  

                  有没有办法比较它们,只返回一组 4 和 5?

                  Is there a way to compare them and only have a set of 4 and 5 returned?

                  推荐答案

                  试试这个

                  test2.removeAll(test1);
                  

                  Set#removeAll

                  从此集合中删除指定集合中包含的所有元素(可选操作).如果指定的集合也是一个集合,这个操作有效地修改这个集合,使其值是两个集合的不对称集合差.

                  Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

                  这篇关于获取两组之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <tfoot id='m2MSS'></tfoot>
                    <bdo id='m2MSS'></bdo><ul id='m2MSS'></ul>
                  • <legend id='m2MSS'><style id='m2MSS'><dir id='m2MSS'><q id='m2MSS'></q></dir></style></legend>

                      <tbody id='m2MSS'></tbody>

                            <i id='m2MSS'><tr id='m2MSS'><dt id='m2MSS'><q id='m2MSS'><span id='m2MSS'><b id='m2MSS'><form id='m2MSS'><ins id='m2MSS'></ins><ul id='m2MSS'></ul><sub id='m2MSS'></sub></form><legend id='m2MSS'></legend><bdo id='m2MSS'><pre id='m2MSS'><center id='m2MSS'></center></pre></bdo></b><th id='m2MSS'></th></span></q></dt></tr></i><div id='m2MSS'><tfoot id='m2MSS'></tfoot><dl id='m2MSS'><fieldset id='m2MSS'></fieldset></dl></div>

                            <small id='m2MSS'></small><noframes id='m2MSS'>