java + +,--, prefix suffix expression values, and ^ values are calculated

Source: Internet
Author: User

 PackageExercise 1;/*** + +--some calculations with ^ *@authorSeeclanukyo **/ Public classTest4 { Public Static voidMain (string[] args) {inti = 3; intb = (i++) + (--)-(++i) + (i++); /*** The first i++ is 3 for + calculation, then 4, the second is to decrement 4 to 3, the third ++i,3 to 4, the fourth i++ at 4 o'clock, and then 5. * * So 3+3-4+4=6*/System.out.println (b); //////////////////////////////        intj = 6; intK = (j + +)-(--) + (i++)-(---j); /*** The first J is calculated at 6 o'clock, then 7 second I at the end of the 5, then-I becomes 4 the third i++ is calculated at 4 o'clock, then becomes 5 fourth--j, becomes 6 * * So 6-4+4-6=0 */System.out.println (k); //////////////////////////////        intQ = 32; intP = 64; intresult =--q + p++-q + p++ + q---Q; /*** 31+64 (+) -31+65 (+31) -30 31+64-31+65+31-30=130*/System.out.println (Result); //////////////////////////////        intx = 6; inty = 9; X= x ^y; Y= x ^y; X= y ^ x ^ x ^y; /*** First get numeric binary 6[0110], 9[1001] <-short first with 4 bit * * x:0110 1001 = 1111 * * y:111  1 1001 = 0110 * * x: * 0110 * 1111 = 1001 * 1111 ^ 1001 = 0110↓* 0110 ^ 0110 = 0000 * * x:0*/System.out.println (x); }}

Afraid of their own forget, paste it!

~~~~~~~~~~~~~~~

java + +,--, prefix suffix expression values, and ^ values are calculated

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.