久久久久久久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可以改變的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

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

                  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 所說,字符串在 Java 中是不可變的.這意味著字符串對象永遠不會改變.這并不意味著您不能更改字符串變量,只是您不能更改字符串的底層內存表示.例如:

                  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!";
                  

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

                  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.

                  我想最好的說法是,當示例的第 2 行執行時,內存中的一個新字符串是由原始字符串和添加到其中的字符串的串聯創建的.str 變量只是對內存位置的引用,然后更改為指向剛剛創建的新變量.

                  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.

                  我對這一點并不是特別了解,但據我了解,這就是所有非原始"值都會發生的情況.任何從 Object 派生的東西都遵循這些規則.原始值,例如 ints、bools、chars、float 和 doubles 允許更改內存中的實際值.所以,從這里:

                  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;
                  

                  內存中的實際值發生變化.此代碼示例不會創建新對象并更改引用,而是僅更改 num 變量在內存中的值.

                  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.

                  至于為什么會這樣,這只是Java制造商的設計決定.我相信有人會評論為什么會這樣,但我不知道.

                  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.

                  這篇關于字符串不能改變.但是int、char可以改變的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 原語?)
                  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>
                            主站蜘蛛池模板: 免费精品视频一区 | 久久国产精品视频 | 男女一区二区三区 | 亚洲欧美在线观看 | 久久国产精品免费 | 呦呦在线视频 | 美国av毛片 | 亚洲久久一区 | 久久久激情视频 | 中文字幕亚洲区一区二 | 久久久成人免费视频 | 超碰在线免费av | 国产天天操 | 国产精品a久久久久 | 国产一区二区视频在线 | 午夜在线视频 | 欧美一区二区免费 | yiren22 亚洲综合 | 国产精品久久久久久久久久久免费看 | 国产精品日韩欧美一区二区三区 | 一级毛片免费完整视频 | 97人人澡人人爽91综合色 | 亚洲综合一区二区三区 | 亚洲精品无 | 欧美一区二区在线观看视频 | 日韩av美女电影 | 91资源在线观看 | 午夜午夜精品一区二区三区文 | 成人精品国产免费网站 | 日韩精品免费视频 | 亚洲精品一区二区另类图片 | 成人免费黄色片 | 好姑娘高清在线观看电影 | 国产一级免费视频 | 精品久久国产 | 国产一级毛片精品完整视频版 | 亚洲精品一区在线观看 | 欧美精品一区二区在线观看 | 天天操天天射综合网 | 国产一区二区影院 | 亚洲国产成人在线视频 |