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

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

    <tfoot id='tmq30'></tfoot><legend id='tmq30'><style id='tmq30'><dir id='tmq30'><q id='tmq30'></q></dir></style></legend>

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

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

        int 數組初始化

        int array initialization(int 數組初始化)

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

          • <legend id='UoQsB'><style id='UoQsB'><dir id='UoQsB'><q id='UoQsB'></q></dir></style></legend>
            • <small id='UoQsB'></small><noframes id='UoQsB'>

              <tfoot id='UoQsB'></tfoot>

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

                  <tbody id='UoQsB'></tbody>

                • 本文介紹了int 數組初始化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在這里有一個與 Java 相關的簡單問題.假設您有一個 int 數組作為實例變量:

                  I have here a simple question related to Java. Let's say you have an int array as instance variable:

                  int[] in = new int[5];
                  

                  所以,現在默認情況下它包含 5 個零.但是,如果您有與局部變量相同的數組怎么辦.它是否被初始化為零?那不是家庭作業,我正在學習 Java 語言.最好的問候

                  So, now by default it contains 5 zeros. But what if you have the same array as local variable. Does it get initialized to zeros? That is not a homework, I am learning Java language. Best regards

                  推薦答案

                  首先要了解的是,本地變量存儲在堆棧 未使用其默認值顯式初始化.而 實例變量 存儲在 Heap 中,并且默認情況下使用它們的 默認值 進行初始化.

                  First thing to understand is that, local varibles are stored on stack which are not initialized explicitly with their default values. While instance variables are stored on Heap, and they are by default initialized with their default value.

                  此外,對象也在 Heap 上創建,無論實例引用變量是持有其引用還是局部引用變量.

                  Also, objects are also created on Heap, regardless of whether an instance reference variable is holding its reference, or a local reference variable.

                  現在,當您將這樣的數組引用聲明為局部變量并使用數組對其進行初始化時,會發生什么:-

                  Now, what happens is, when you declare your array reference like this as local variable, and initialize it with an array: -

                  int[] in = new int[5];
                  

                  數組引用(in)存儲在stack上,并且為數組分配了內存,該數組能夠在上保存5個整數元素em>heap(記住,對象是在堆上創建的).然后,在 Heap 上分配 5 個連續的內存位置 (size = 5),用于存儲 integer 值.并且數組對象上的每個 index 都按順序保存了對這些內存位置的 reference.然后數組引用指向該數組.因此,由于在堆上分配了 5 個整數值的內存,因此將它們初始化為默認值.

                  The array reference (in) is stored on stack, and a memory is allocated for array capable of holding 5 integer elements on heap (Remember, objects are created on Heap). Then, 5 contiguous memory location (size = 5), for storing integer value are allocated on Heap. And each index on array object holds a reference to those memory location in sequence. Then the array reference points to that array. So, since memory for 5 integer values are allocated on Heap, they are initialized to their default value.

                  而且,當你聲明你的數組引用時,不要用任何數組對象初始化它:-

                  And also, when you declare your array reference, and don't initialize it with any array object: -

                  int[] in;
                  

                  數組引用是在 Stack 上創建的(因為它是一個局部變量),但默認情況下它不會初始化為數組,也不會初始化為 null,與實例變量一樣.

                  The array reference is created on Stack (as it is a local variable), but it does not gets initialized to an array by default, and neither to null, as is the case with instance variables.

                  所以,這就是使用第一種數組聲明和初始化方式時的分配方式:-

                  So, this is how allocation looks like when you use the first way of array declaration and initialization: -

                  "Your array reference"
                       "on stack"    
                  
                         |    |          "Array object on Heap"
                         +----+                  
                         | in |---------->  ([0, 0, 0, 0, 0])
                         +----+
                         "Stack"                  "Heap"
                  

                  這篇關于int 數組初始化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

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

                  <tfoot id='sRXJU'></tfoot>
                    <bdo id='sRXJU'></bdo><ul id='sRXJU'></ul>
                    <legend id='sRXJU'><style id='sRXJU'><dir id='sRXJU'><q id='sRXJU'></q></dir></style></legend>
                      <tbody id='sRXJU'></tbody>

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

                            主站蜘蛛池模板: 啪啪免费| av毛片| 久久免费精品 | 亚洲精品久久久久久宅男 | 国产剧情一区二区三区 | 国产免费麻豆视频 | 91视频电影 | 国外成人在线视频网站 | 中文字幕在线观看第一页 | 性视频网 | 日本一二三区在线观看 | 免费一区二区 | 99精品视频免费在线观看 | 日韩成人在线观看 | 超碰人人做 | 久久久久久久久国产精品 | 二区在线观看 | av毛片免费| 久久成人av | 蜜桃在线视频 | 男人久久天堂 | 国产一级片免费看 | 国产精品伦理一区二区三区 | 爱高潮www亚洲精品 中文字幕免费视频 | 日韩一区av | 国产欧美日韩一区二区三区在线观看 | av网站免费观看 | 日韩欧美一级精品久久 | 一道本视频 | 国产黄色精品 | 中文字幕在线精品 | 毛色毛片免费看 | 国产精品视频免费看 | 亚洲品质自拍视频 | 古装三级在线播放 | 成人免费看片又大又黄 | 91综合在线观看 | 国产精品视频一区二区三区不卡 | 国产成人99久久亚洲综合精品 | 久久成 | 蜜桃在线一区二区三区 |