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.

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

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

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                  <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'>