• <legend id='6S4ol'><style id='6S4ol'><dir id='6S4ol'><q id='6S4ol'></q></dir></style></legend>

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

        <small id='6S4ol'></small><noframes id='6S4ol'>

      1. 从字符的 ArrayList 中删除一个字符

        时间:2023-07-26

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

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

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

            <tfoot id='PkBmJ'></tfoot>

                • <bdo id='PkBmJ'></bdo><ul id='PkBmJ'></ul>

                    <tbody id='PkBmJ'></tbody>
                  本文介绍了从字符的 ArrayList 中删除一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在循环中面临这种不需要的 charint 转换.假设我有这个字符列表,我想删除其中一个:

                  I am facing with this unwanted char to int conversion in a loop. Say I have this List of Characters and I want to remove one of those:

                  List<Character> chars = new ArrayList<>();
                  chars.add('a');
                  chars.add('b');
                  chars.add('c');
                  chars.remove('a');  // or chars.remove('a'-'0');
                  

                  所以 'a' 被解释为它的 int 值,我得到一个 IndexOutOfBoundsException 异常.有什么简单的解决方法吗?

                  so 'a' is interpreted as its int value and I'm getting an IndexOutOfBoundsException exception. Is there any easy workaround for this?

                  推荐答案

                  一个 char 被提升为一个 int,它优先于自动装箱,所以 remove(int) 被调用而不是 remove(Object)你可能已经直观地期待了.

                  A char is promoted to an int, which takes precedence over autoboxing, so remove(int) is called instead of remove(Object) you may have intuitively expect.

                  您可以通过自己装箱参数来强制调用正确"的方法:

                  You can force the "right" method to be called by boxing the argument yourself:

                  chars.remove(Character.valueOf('a'));
                  

                  这篇关于从字符的 ArrayList 中删除一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:未闭合字符文字错误 下一篇:如何在正则表达式中表示双引号字符(&quot;)?

                  相关文章

                  最新文章

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

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

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