久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

    1. <i id='G1S1o'><tr id='G1S1o'><dt id='G1S1o'><q id='G1S1o'><span id='G1S1o'><b id='G1S1o'><form id='G1S1o'><ins id='G1S1o'></ins><ul id='G1S1o'></ul><sub id='G1S1o'></sub></form><legend id='G1S1o'></legend><bdo id='G1S1o'><pre id='G1S1o'><center id='G1S1o'></center></pre></bdo></b><th id='G1S1o'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='G1S1o'><tfoot id='G1S1o'></tfoot><dl id='G1S1o'><fieldset id='G1S1o'></fieldset></dl></div>

      <tfoot id='G1S1o'></tfoot>
      • <bdo id='G1S1o'></bdo><ul id='G1S1o'></ul>
    2. Java將字符添加到字符串

      Java add chars to a string(Java將字符添加到字符串)

    3. <tfoot id='uYxQO'></tfoot>
    4. <i id='uYxQO'><tr id='uYxQO'><dt id='uYxQO'><q id='uYxQO'><span id='uYxQO'><b id='uYxQO'><form id='uYxQO'><ins id='uYxQO'></ins><ul id='uYxQO'></ul><sub id='uYxQO'></sub></form><legend id='uYxQO'></legend><bdo id='uYxQO'><pre id='uYxQO'><center id='uYxQO'></center></pre></bdo></b><th id='uYxQO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uYxQO'><tfoot id='uYxQO'></tfoot><dl id='uYxQO'><fieldset id='uYxQO'></fieldset></dl></div>

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

            <bdo id='uYxQO'></bdo><ul id='uYxQO'></ul>

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

                  <tbody id='uYxQO'></tbody>
                本文介紹了Java將字符添加到字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我在一個 java 程序中有兩個字符串,我想以某種方式混合它們以形成兩個新字符串.為此,我必須從每個字符串中提取一些組成字符并將它們添加以形成新字符串.我有這樣的代碼(this.eka 和 this.toka 是原始字符串):

                String muutettu1 = new String();字符串 muutettu2 = 新字符串();muutettu1 += this.toka.charAt(0) + this.toka.charAt(1) + this.eka.substring(2);muutettu2 += this.eka.charAt(0) + this.eka.charAt(1) + this.toka.substring(2);System.out.println(muutettu1 + " " + muutettu2);

                我正在獲取 .charAt(x) 部分的數字,那么如何將字符轉換為字符串?

                解決方案

                只要使用 always use substring() 而不是 charAt()


                在這種特殊情況下,值是可變的,因此,我們可以使用內置的 String 類方法 substring() 來解決這個問題(@see 下面的例子):

                特定于 OP 用例的示例:

                <代碼>muutettu1 += toka.substring(0,1) + toka.substring(1,2) + eka.substring(2);muutettu2 += eka.substring(0,1) + eka.substring(1,2) + toka.substring(2);


                概念示例,(即示例顯示在嘗試使用此概念解決問題時采用的一般方法)

                <代碼>muutettu1 += toka.substring(x,x+1) + toka.substring(y,y+1) + eka.substring(z);muutettu2 += eka.substring(x,x+1) + eka.substring(y,y+1) + toka.substring(z);

                <塊引用>

                ...其中 x,y,z 是保存要提取的位置的變量."

                I have two strings in a java program, which I want to mix in a certain way to form two new strings. To do this I have to pick up some constituent chars from each string and add them to form the new strings. I have a code like this(this.eka and this.toka are the original strings):

                String muutettu1 = new String();
                String muutettu2 = new String();
                muutettu1 += this.toka.charAt(0) + this.toka.charAt(1) + this.eka.substring(2);
                muutettu2 += this.eka.charAt(0) + this.eka.charAt(1) + this.toka.substring(2);
                System.out.println(muutettu1 + " " + muutettu2);
                

                I'm getting numbers for the .charAt(x) parts, so how do I convert the chars to string?

                解決方案

                Just use always use substring() instead of charAt()


                In this particular case, the values are mutable, consequently, we can use the built in String class method substring() to solve this problem (@see the example below):

                Example specific to the OP's use case:

                
                    muutettu1 += toka.substring(0,1) + toka.substring(1,2) + eka.substring(2);
                   
                    muutettu2 += eka.substring(0,1) + eka.substring(1,2) + toka.substring(2);
                
                


                Concept Example, (i.e Example showing the generalized approach to take when attempting to solve a problem using this concept)

                
                    muutettu1 += toka.substring(x,x+1) + toka.substring(y,y+1) + eka.substring(z);
                
                    muutettu2 += eka.substring(x,x+1) + eka.substring(y,y+1) + toka.substring(z);
                
                

                "...Where x,y,z are the variables holding the positions from where to extract."

                這篇關于Java將字符添加到字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)

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

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

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

                            <tbody id='Ogpch'></tbody>
                          <tfoot id='Ogpch'></tfoot>
                        • 主站蜘蛛池模板: 亚洲精品888| 欧美精品在线观看 | 国产日韩精品一区二区三区 | 欧美久久久久久久久 | 国产成人精品一区二 | 人妖av| 欧洲av一区 | 久久成人国产 | 亚洲欧美日韩电影 | 欧美一级二级三级 | 日韩人体视频 | 国产区一区 | 中文字幕亚洲视频 | 在线视频h| 91精品国产自产精品男人的天堂 | 欧美亚洲视频 | 91在线第一页| 久久爱综合 | 国产高清视频 | 久久久国产一区 | 久久国产精品免费 | 亚洲视频免费一区 | 成人一区二区三区在线观看 | 91极品欧美视频 | 色性av | 欧美精品一区二区三区一线天视频 | 欧美中文一区 | 亚洲人成在线播放 | 国产剧情一区 | 国产伦精品一区二区三毛 | 亚洲国产成人一区二区 | 亚洲网站在线观看 | 国产成人99久久亚洲综合精品 | 免费的色网站 | 欧美性猛交一区二区三区精品 | 91精品国产乱码久久久久久久久 | 欧美男人天堂 | 国产精品成人一区二区 | 99久久亚洲 | 欧美日韩精品一区二区三区四区 | 亚洲精品国产综合区久久久久久久 |