Java record-I-operator Operator

Source: Internet
Author: User
  1. When there are several variables involved in the operation, the result type depends on the variable type that represents the largest range in the variables. For example, in the variable that participates in the operation, there is an int, a double floating-point type Double, a short integer, and the last result type is double.

  2. int a = 1;  int b = 2; Double c = (double) A/b;

    In the above code, both A and B are integral types, but the conversion of (double) a converts a to an anonymous variable that is of type double. But note: A itself is still an int type, not a double type, so that a (double) A/b is a double type divided by an int type, and the result is a double type.

  3. Modulo operator: use% representation.

    int a = 5;  int b = 3; int C = a% B;

    The result is 2 because 5 divided by 3 results in 1 + 2.

    The rule of modulus: The result symbol of the modulo is always the same as the sign of the divisor.

    int a = 5;  int b =-3; int C = a% B;

    Dividend is 5, then the result of modulo is 2;

    int a =-5;  int b = 3; int C = a% B;

    Dividend is-5, then the result of modulo is-2;

Java record-I-operator Operator

Related Article

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: 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.