Learning Diary (v) Java operations

Source: Internet
Author: User

When Java is in operation, there are conversions of data types, one of which is automatic type conversion, also known as implicit type conversion, which needs to meet certain conditions:

1. The two types are compatible, such as both integer types or numeric types

2. The scope of the destination type number is greater than the range of the source data

There is also a coercion type conversion, also known as a display type conversion, that sometimes occurs when truncation and narrowing, such as casting a decimal to an integer, discards the fractional portion.

All byte and short types are automatically converted to int when operating, and the result of two byte operations is an int rather than a byte type, and if there are operands in the expression long, the entire expression is promoted to a long type. That is, long if the expression has an operand of type float, the expression is promoted to float, and if the operand is of type double, the expression is promoted to type double.

There are four types of operators in Java, namely arithmetic operators, bitwise operators, relational operators, and logical operators.

Arithmetic operators: + 、-、 *,/,% (or the remainder), + + (increment or call to increase) 、--(decrement or call), + =,-=, *=,/=,%=; it is important to note that when the self-increment and decrement operations are used, the symbols are followed by the first operation, and the symbols are used after the first operation. When the division is performed, the result of the integer operation is to place the decimal digits. The% operation is not the same as C + +, which can also be used on decimals in Java.

Bitwise operators: The temporary phase is almost unused.

Relational operators:>, <, = =, >=, <=,! =; in Java, a = represents an assignment, and two = is equal to.

Logical Operators:&, |,! , &&, | |, ^, &=, |=, ^=, = =,! =,? :; where && and | | The difference between & and | Is that the former has a short circuit function. : Represents a three-mesh operation, or a ternary operation,? Is the logical expression before, and the result is true? And: The value between, otherwise take: the value after.


Learning Diary (v) Java operations

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.