Java interview (1)--Java assignment expression

Source: Internet
Author: User

1Classdemo01{2PublicStaticvoidMain (string[] args) {3//Assignment operator =45//Example 16int a = 1;7System.out.println (a);8//Results 191011//Example 212int a = 1;System.out.println (a=2);14//Results 215//First assignment, then output161718//Example 319int a = 1;20int B = A + (a=2) + A + (a=3);21st//= 1 + (a=2) + A + (a=3)22//= 1 + 2 + A + (a=3)23//= 1 + 2 + 2 + (a=3)24//= 1 + 2 + 2 + 325//= 826System.out.println (a);27System.out.println (b);28//Result 3,8293031//Example 432int a = 1;33int B = (a=a+ (A + (a=2) +a) +a) +334//(A=a+ (A + (a=2) +a) +a)35//A + (A + (a=2) +a) +a a=136//1+ (A + (a=2) +a) +a a=137// 1+ (1+ (a=2) +a) +a a=1 // 1+ (1+ (2) +a) +a a=2 // 1+ (1+ (2) +2) +a a=2// 1+ (1+ (2) +2) +2 a=2  System.out.println (a);  System.out.println (b); // result 8,1144 45 }46}       

Java interview (1)--Java assignment expression

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.