亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - Byte自增問(wèn)題
PHPz
PHPz 2017-04-18 10:56:08
0
5
558
Byte a = 123;
        a++;
        System.out.println(a);// 124
        /*
         * 上面的結(jié)論是: a++的時(shí)候首先是 創(chuàng)建一個(gè)Byte對(duì)象124,然后將a引用指向這個(gè)Byte 124對(duì)象,這個(gè)解釋有問(wèn)題嗎?
         */

        Byte b = 126;
        b = b++;
        System.out.println(b);// 126
        /*
         * 根據(jù)第一段代碼的執(zhí)行結(jié)果;
         * b=b++,的執(zhí)行操作是首相將b引用賦值給b引用,所以沒有改變,然后將b引用所指向的對(duì)象自增(這個(gè)實(shí)現(xiàn)的過(guò)程是創(chuàng)建一個(gè)對(duì)象值為127,
         * 然后讓b引用指向這個(gè)127),如果這樣理解,結(jié)果不應(yīng)該是127嗎
         */

求解,謝謝

PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(5)
大家講道理

b = b++: If you know C++, you can refer to the auto-increment implementation of ++, and you should be able to understand why it is 126

Byte operator++(Byte) {
    Byte temp = *this;
    this->value = this->value + 1;
    return temp;
}

can be understood as b is equal to temp before the operation is incremented

Ty80

++, --Be sure to write it separately, otherwise you will cause trouble for yourself.
For questions like i=i+++++i, I can only despise...

小葫蘆

Resolved
http://blog.csdn.net/brooksyc...
Post to receive points

迷茫

++The difference between b and b++ is actually useless

巴扎黑

Java stack frame contains local variable table and operand stack. The ++ auto-increment operation is direct operation on the value in the local variable table. When i=i++, first push the i in the local variable table into the operand stack. Then add 1 to i in the local variable table to become 127, and then write i (126) in the operand stack back to i in the local variable table, covering the 127 data and changing it to 126. The order of ++i is different. It first increments i in the local variable table and then adds it to the operand stack.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template