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

  • <small id='tD1Jg'></small><noframes id='tD1Jg'>

      1. <legend id='tD1Jg'><style id='tD1Jg'><dir id='tD1Jg'><q id='tD1Jg'></q></dir></style></legend><tfoot id='tD1Jg'></tfoot>

      2. Java:从 char 中解析 int 值

        时间:2023-07-28

            <tbody id='vbHI9'></tbody>
        1. <small id='vbHI9'></small><noframes id='vbHI9'>

          <tfoot id='vbHI9'></tfoot>

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

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

                <bdo id='vbHI9'></bdo><ul id='vbHI9'></ul>
                • 本文介绍了Java:从 char 中解析 int 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我只是想知道是否有更好的解决方案来从字符串中的字符解析数字(假设我们知道索引 n 处的字符是数字).

                  I just want to know if there's a better solution to parse a number from a character in a string (assuming that we know that the character at index n is a number).

                  String element = "el5";
                  String s;
                  s = ""+element.charAt(2);
                  int x = Integer.parseInt(s);
                  
                  //result: x = 5
                  

                  (不用说这只是一个例子)

                  (useless to say that it's just an example)

                  推荐答案

                  试试Character.getNumericValue(char).

                  String element = "el5";
                  int x = Character.getNumericValue(element.charAt(2));
                  System.out.println("x=" + x);
                  

                  产生:

                  x=5
                  

                  getNumericValue(char) 的好处是它也适用于 "el٥""el५" 等字符串,其中 ٥ 分别是东方阿拉伯语和印地语/梵语中的数字 5.

                  The nice thing about getNumericValue(char) is that it also works with strings like "el٥" and "el५" where ٥ and are the digits 5 in Eastern Arabic and Hindi/Sanskrit respectively.

                  这篇关于Java:从 char 中解析 int 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么 char[] 优于 String 的密码? 下一篇:Java - char、int 转换

                  相关文章

                  最新文章

                  1. <legend id='4oWGU'><style id='4oWGU'><dir id='4oWGU'><q id='4oWGU'></q></dir></style></legend>

                    • <bdo id='4oWGU'></bdo><ul id='4oWGU'></ul>
                  2. <small id='4oWGU'></small><noframes id='4oWGU'>

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

                      <tfoot id='4oWGU'></tfoot>