Crazy JAVA Post ++, java

Source: Internet
Author: User

Crazy JAVA Post ++, java

I. x ++


Therefore, after the execution of x ++, the x value of the local variable area is directly 2;

Iinc: Specifies the int type variable to add the specified value. Note that it is a variable. In my explanation, iinc directly operates on local variables rather than the operation stack!★★★★

OUTPUT: 2

2. x = x ++ x


2. decomposition:X = x ++ x; a. 1 ++ assigns a value to x B. 1 + 2 of the local variable area to apply the 2 pressure stack of the local variable area.
C. x = 3 operation result assignment
2. Memory

 

OUTPUT: 3
  Iii. x = x+ X ++
1. Pay attention to the differences between operations 2, 3, 4 and 2:
Because x ++ is before the addition operation, iinc is used first, and then iload is used. Because x ++ is behind the addition operation, therefore, we can obtain the expected two operands for addition operations. Therefore, we first obtain two identical addition operations; 2. decomposition:X = x + x ++; a. 1 + 1 is pushed into the operation stack B. 1 + + local variable area to 2 c. x = 2 the operation stack is assigned a value to the local variable x OUTPUT: 2
Iv. x = x ++
 
OUTPUT: 1 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.