久久久久久久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 數(shù)組初始化

        int array initialization(int 數(shù)組初始化)

            <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 數(shù)組初始化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在這里有一個與 Java 相關(guān)的簡單問題.假設(shè)您有一個 int 數(shù)組作為實例變量:

                  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];
                  

                  所以,現(xiàn)在默認情況下它包含 5 個零.但是,如果您有與局部變量相同的數(shù)組怎么辦.它是否被初始化為零?那不是家庭作業(yè),我正在學習 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 上創(chuàng)建,無論實例引用變量是持有其引用還是局部引用變量.

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

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

                  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];
                  

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

                  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.

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

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

                  int[] in;
                  

                  數(shù)組引用是在 Stack 上創(chuàng)建的(因為它是一個局部變量),但默認情況下它不會初始化為數(shù)組,也不會初始化為 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.

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

                  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"
                  

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

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

                  相關(guān)文檔推薦

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

                            主站蜘蛛池模板: 欧美综合国产精品久久丁香 | 免费成年网站 | 日韩欧美在线一区 | 亚洲成人午夜电影 | 99色综合| 欧美国产一区二区 | 精品九九| 成年人黄色小视频 | av手机免费在线观看 | 日韩精品一区二区三区中文在线 | 97精品国产97久久久久久免费 | 色频 | 欧美视频1| 国产三区在线观看视频 | 成人在线亚洲 | 日韩在线中文 | 91精品国产91久久久久久吃药 | 国产精品一区二区三区在线 | 精品三区 | 亚洲国产精品99久久久久久久久 | 超碰人人人人 | 男人的天堂中文字幕 | 日韩精品国产精品 | 久视频在线 | 精品乱码一区二区三四区 | 日韩成人免费av | 日韩精品影院 | 99久久99| 精品三区 | 亚洲高清在线观看 | 午夜免费观看网站 | 五月激情婷婷在线 | 国产在线一区二区 | 亚洲免费在线 | 免费精品在线视频 | 国产激情网 | 欧美成视频 | 欧美激情五月 | 男女啪啪高潮无遮挡免费动态 | 成人欧美一区二区三区黑人孕妇 | 国产一区不卡 |