Java Arithmetic operators

Source: Internet
Author: User

int x=6274; x=x/1000*1000System.out.println (x);

The result is 6000, because 6274 divided by 1000 equals 6.274 for the dauble type automatically ignores the number of digits after the decimal point, so 6*1000 equals 6000;

//   +  -*/  % +System.out.println ("5+5=" +5+5);

The result is 5+5=55;

//  ++ -- int a=3, b; // ++a; b=a++; System.out.println ("a=" +a+ ", b=" +b);

The order of operations is a first assigns the value to B, then the self-increment, so the result a=4,b=3

int i;i=i++; System.out.println (i);

Result is 1

// =  + = =    *=     /=     %=short s=3;  // s+=4;  Automatic forced conversion of s=s+4;    No casts are required, and a strongturn is needed (short), otherwise the compilation will not pass.

Java Arithmetic operators

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.