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

      <tfoot id='PsfPi'></tfoot>

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

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

      1. 逐个字符比较java中的两个字符串

        时间:2023-07-26
      2. <small id='YpV7O'></small><noframes id='YpV7O'>

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

                  <tbody id='YpV7O'></tbody>
                <i id='YpV7O'><tr id='YpV7O'><dt id='YpV7O'><q id='YpV7O'><span id='YpV7O'><b id='YpV7O'><form id='YpV7O'><ins id='YpV7O'></ins><ul id='YpV7O'></ul><sub id='YpV7O'></sub></form><legend id='YpV7O'></legend><bdo id='YpV7O'><pre id='YpV7O'><center id='YpV7O'></center></pre></bdo></b><th id='YpV7O'></th></span></q></dt></tr></i><div id='YpV7O'><tfoot id='YpV7O'></tfoot><dl id='YpV7O'><fieldset id='YpV7O'></fieldset></dl></div>
                1. 本文介绍了逐个字符比较java中的两个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我是java的初学者,我正在尝试逐个字符比较java中的两个字符串,并通过以下代码找到它们有多少不同的字符,但它不起作用,

                  I am beginner in java, I am trying to compare two strings in java char by char and find how many different chars they have by the following code but it doesn't work,

                       min is the min between the 2 strings
                  
                       for(int i=0; i<min-1; i++){
                              s1 = w1.substring(j,j++);
                              s2 = w2.substring(j,j++);
                  
                              if (! s1.equalsIgnoreCase(s2) ){
                                  counter++;    
                              }
                        }`
                  

                  有什么建议吗?

                  推荐答案

                  使用这个:

                  char[] first  = w1.toLowerCase().toCharArray();
                  char[] second = w2.toLowerCase().toCharArray();
                  
                  int minLength = Math.min(first.length, second.length);
                  
                  for(int i = 0; i < minLength; i++)
                  {
                          if (first[i] != second[i])
                          {
                              counter++;    
                          }
                  }
                  

                  这篇关于逐个字符比较java中的两个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何以相反的顺序获取 char 数组? 下一篇:为什么我不能写 ch=ch+1;而不是 ch++;尽管它们具有

                  相关文章

                  最新文章

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

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

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

                    2. <tfoot id='ceiJj'></tfoot>
                        <bdo id='ceiJj'></bdo><ul id='ceiJj'></ul>