Java Learning Note 3-operators

Source: Internet
Author: User
Tags bitwise operators


Java basic operator: + 、-、 *,/,%, =, = =,! =, + =,-=.

Priority: First multiplication after the addition and subtraction, if the connector + number will be prioritized forward matching, such as a+++++b, will be interpreted as a++ + + +b, so will error, you need to use parentheses to isolate (a++) + (++b).


Object references If you assign a reference to an object, 2 objects will point to the same reference, and one object's reference will be re-assigned to another object, such as

ClassName ClassA = new ClassName ();

ClassName ClassB = new ClassName ();

ClassA = ClassB;

classa.x = xxx;

Then classb.x also for XXX.


Relational operators:<, >, <=, >=, = =,! =, equals ().

Equals () is used primarily to compare the contents of an object, not a reference to an object (the result is always false if compared).


Logical operator:&&, | | 、!。

Operation Short-circuit: If the logical operator && in the connection of multiple judging conditions, there is a condition that does not match the result is directly inconsistent, if the match must be judged that all conditions are met.


Direct constants:

d hex
front (rear) suffix
l
f float
double
0 (0~7) octal


Exponential notation: E represents the power of 10.

Bitwise operators:

operator TD width= "442" style= "margin:0px;" > Two operands, the same result is 0, the result is 1
two operand median is 1, result is 1, otherwise the result is 0
or (|) Two bits as long as one is 1, then the result is 1, otherwise 0
non (~)

Shift operators: Left shift operator (<<), right shift operator (>>), unsigned Right shift operator (>>>).

Operator Overloading: +, + =.


Type conversion operators:

The extended conversion (int->float) can not explicitly indicate the type of conversion, and the narrowing conversion (Float->int) must specify the type of the cast to indicate the expected;

The principle of rounding is not performed when casting a type, and the tail is always truncated;

You can use Math.Round (XXX) to achieve rounding effect;

When used with the "large" type and the "small" type, the program defaults to the "large" type for unification, such as int and long, and the result is long.


All Java data types are the same size in all machine stores (see Java Learning Note 2), so no sizeof () is required to calculate.



Long press attention "I'm Programming"

650) this.width=650; "Src=" https://mmbiz.qlogo.cn/mmbiz_png/ Rkgihvg2qb2d5owd8xepal427uv7f6updiaiag7disuyrcwfa0zonkdqa5jfhw0v0dz7kzrtowb7uk9bxvibcqyibq/0?wx_fmt=png "style= "Margin:0px;padding:0px;height:auto;" alt= "0?wx_fmt=png"/>

See more | How to Think | More Practice

No Kuibu, not even thousands of miles.



This article is from the "I am Programming" blog, please be sure to keep this source http://sylan215.blog.51cto.com/681991/1923856

Java Learning Note 3-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.