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

      <tfoot id='KJUUE'></tfoot>

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

      1. Java - 将小写转换为大写而不使用 toUppercase()

        时间:2023-07-27

        • <legend id='tiScB'><style id='tiScB'><dir id='tiScB'><q id='tiScB'></q></dir></style></legend>

            <tbody id='tiScB'></tbody>
            <bdo id='tiScB'></bdo><ul id='tiScB'></ul>
          • <tfoot id='tiScB'></tfoot>

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

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

                  本文介绍了Java - 将小写转换为大写而不使用 toUppercase()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试创建一个简短的程序,它将所有大写字母转换为小写字母(从命令行输入).

                  I'm trying to create a short program that would convert all letters that are uppercase to lowercase (from the command line input).

                  以下编译但没有给我我期望的结果.这会是什么原因??

                  The following compiles but does not give me the result I am expecting. What would be the reason for this??

                  例如)java toLowerCase BANaNa -> 给出香蕉的输出

                  Eg) java toLowerCase BANaNa -> to give an output of banana

                   public class toLowerCase{
                          public static void main(String[] args){
                  
                              toLowerCase(args[0]);
                          }
                  
                          public static void toLowerCase(String a){
                  
                              for (int i = 0; i< a.length(); i++){
                  
                                  char aChar = a.charAt(i);
                                  if (65 <= aChar && aChar<=90){
                                      aChar = (char)( (aChar + 32) ); 
                                  }
                  
                                  System.out.print(a);
                              }
                           }   
                      }
                  

                  推荐答案

                  对我来说看起来像是作业,只是一个提示.您正在打印字符串 a,而您正在修改 char 类型 aChar,而不是修改原始字符串 a.(记住字符串是不可变的).

                  Looks like homework to me, Just a hint. You are printing string a whereas you are modifying the char type aChar, its not modifying the original string a. (Remember strings are immutable).

                  这篇关于Java - 将小写转换为大写而不使用 toUppercase()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将文本文件读入Java中的char数组 下一篇:java - 如何检查Java句子中有多少个辅音和元音?

                  相关文章

                  最新文章

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

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

                      <tfoot id='mFv8E'></tfoot>