Short S = 1; S = S + 1; short S = 1; S + = 1; is there a difference ?? If so, what is the difference? If not, what is the value?

Source: Internet
Author: User
Short S = 1; S = S + 1; CompilationFailedShort S = 1; S + = 1; why can I compilePassSo? Another problem is that implicit type conversion can be automatically converted from small to large, that is, byte-> short-> int-> long. If the precision is lost in turn, it must be performed.Display type conversionS + = 1 means different from S = S + 1,
S = S + 1: Execute S + 1 first and then assign the result to S. Because 1 is of the int type, the return value of S + 1 is int,
The compiler automatically performs implicit type conversion. Therefore, an error occurs when an int type is assigned to short,
S + = 1 is different because it is the + = Operator. in parsing, S + = 1 is equivalent to S = (short) (S + 1). Doubling is
S + = 1 <=> S = (S type) (S + 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.