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

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

    1. <tfoot id='ZVNwW'></tfoot>
          <bdo id='ZVNwW'></bdo><ul id='ZVNwW'></ul>

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

      1. <legend id='ZVNwW'><style id='ZVNwW'><dir id='ZVNwW'><q id='ZVNwW'></q></dir></style></legend>
      2. 字符串不能改變.但是int、char可以改變

        String can#39;t change. But int, char can change(字符串不能改變.但是int、char可以改變)
          <tfoot id='o4qXe'></tfoot>

        1. <small id='o4qXe'></small><noframes id='o4qXe'>

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

              • <i id='o4qXe'><tr id='o4qXe'><dt id='o4qXe'><q id='o4qXe'><span id='o4qXe'><b id='o4qXe'><form id='o4qXe'><ins id='o4qXe'></ins><ul id='o4qXe'></ul><sub id='o4qXe'></sub></form><legend id='o4qXe'></legend><bdo id='o4qXe'><pre id='o4qXe'><center id='o4qXe'></center></pre></bdo></b><th id='o4qXe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='o4qXe'><tfoot id='o4qXe'></tfoot><dl id='o4qXe'><fieldset id='o4qXe'></fieldset></dl></div>
                  本文介紹了字符串不能改變.但是int、char可以改變的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我讀到在 Java 中,String 類型的對(duì)象不能改變.但是 int 和 char 變量可以.為什么?可以舉個(gè)例子嗎?

                  I've read that in Java an object of type String can't change. But int and char variables can. Why is it? Can you give me an example?

                  謝謝.(我是新人-_-)

                  Thank you. (I am a newer -_- )

                  推薦答案

                  正如 bzabhi 所說(shuō),字符串在 Java 中是不可變的.這意味著字符串對(duì)象永遠(yuǎn)不會(huì)改變.這并不意味著您不能更改字符串變量,只是您不能更改字符串的底層內(nèi)存表示.例如:

                  As bzabhi said, strings are immutable in Java. This means that a string object will never change. This does not mean you can not change string variables, just that you cannot change the underlying memory representation of the string. for an example:

                  String str = "Hello";
                  str += " World!";
                  

                  在這些行執(zhí)行之后,str 將指向內(nèi)存中的一個(gè)新字符串.原始的Hello"字符串仍然存在于內(nèi)存中,但很可能不會(huì)存在太久.假設(shè)沒(méi)有情有可原的情況,任何東西都不會(huì)指向原始字符串,所以它將被垃圾收集.

                  Following the execution of these lines, str will point to a new string in memory. The original "Hello" string still exists in memory, but most likely it will not be there for long. Assuming that there are no extenuating circumstances, nothing will be pointing at the original string, so it will be garbage collected.

                  我想最好的說(shuō)法是,當(dāng)示例的第 2 行執(zhí)行時(shí),內(nèi)存中的一個(gè)新字符串是由原始字符串和添加到其中的字符串的串聯(lián)創(chuàng)建的.str 變量只是對(duì)內(nèi)存位置的引用,然后更改為指向剛剛創(chuàng)建的新變量.

                  I guess the best way to put this would be to say that when line 2 of the example executes, a new string in memory is created from the concatenation of the original string and the string being added to it. The str variable, which is just a reference to a memory location, is then changed to point at the new variable that was just created.

                  我對(duì)這一點(diǎn)并不是特別了解,但據(jù)我了解,這就是所有非原始"值都會(huì)發(fā)生的情況.任何從 Object 派生的東西都遵循這些規(guī)則.原始值,例如 ints、bools、chars、float 和 doubles 允許更改內(nèi)存中的實(shí)際值.所以,從這里:

                  I am not particularly knowledgeable on the point, but, as I understand it, this is what happens with all "non-primitive" values. Anything that at some point derives from Object follows these rules. Primitive values, such as ints, bools, chars, floats and doubles allow the actual value in memory to be changed. So, from this:

                  int num = 5;
                  num += 2;
                  

                  內(nèi)存中的實(shí)際值發(fā)生變化.此代碼示例不會(huì)創(chuàng)建新對(duì)象并更改引用,而是僅更改 num 變量在內(nèi)存中的值.

                  the actual value in memory changes. Rather than creating a new object and changing the reference, this code sample will simply change the value in memory for the num variable.

                  至于為什么會(huì)這樣,這只是Java制造商的設(shè)計(jì)決定.我相信有人會(huì)評(píng)論為什么會(huì)這樣,但我不知道.

                  As for why this is true, it is simply a design decision by the makers of Java. I'm sure someone will comment on why this was made, but that isn't something I know.

                  這篇關(guān)于字符串不能改變.但是int、char可以改變的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯(cuò)誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語(yǔ)句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數(shù)的三元表達(dá)式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲(chǔ)出現(xiàn)的每個(gè)字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉(zhuǎn)換 char 原語(yǔ)?)
                  1. <i id='FWg5L'><tr id='FWg5L'><dt id='FWg5L'><q id='FWg5L'><span id='FWg5L'><b id='FWg5L'><form id='FWg5L'><ins id='FWg5L'></ins><ul id='FWg5L'></ul><sub id='FWg5L'></sub></form><legend id='FWg5L'></legend><bdo id='FWg5L'><pre id='FWg5L'><center id='FWg5L'></center></pre></bdo></b><th id='FWg5L'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FWg5L'><tfoot id='FWg5L'></tfoot><dl id='FWg5L'><fieldset id='FWg5L'></fieldset></dl></div>
                    <tfoot id='FWg5L'></tfoot>

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

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

                          1. <legend id='FWg5L'><style id='FWg5L'><dir id='FWg5L'><q id='FWg5L'></q></dir></style></legend>
                              <tbody id='FWg5L'></tbody>
                            主站蜘蛛池模板: 在线视频亚洲 | 久久亚洲一区二区三区四区 | 欧美日韩网站 | 国产久视频 | 成人国产精品免费观看 | 色婷婷亚洲国产女人的天堂 | 天天干天天操天天射 | 97人人超碰 | 紧缚调教一区二区三区视频 | 欧美伊人久久久久久久久影院 | 国产一区二区免费 | 一区视频 | 久久成人人人人精品欧 | 色天堂影院 | 日本免费黄色一级片 | 国产成人自拍av | 在线一区二区国产 | 狠狠操狠狠搞 | 日韩国产免费 | 亚洲成人免费视频在线观看 | 天天碰夜夜操 | 欧美a√| 久草免费在线视频 | 天天操夜夜看 | 久久久久久久av | 久久久久久国产精品免费免费 | 亚洲一区中文 | 国产精品一区二区在线播放 | 天堂中文字幕av | 久久精品亚洲国产奇米99 | 国产精品揄拍一区二区久久国内亚洲精 | 91视频大全 | 欧美一级片黄色 | 久热国产在线 | 欧美高清视频 | 久久av.com| 精品国产一区二区三区日日嗨 | 日韩av中文 | 国产精品久久久久久久免费大片 | 激情影院久久 | 国产一区二区免费在线 |