Java Programming Ideas: 3rd Chapter operator

Source: Internet
Author: User
Tags arithmetic arithmetic operators logical operators

At the bottom, the data in Java is manipulated by operators.

3.1 Simpler Print Statements

Put the SYSTEM.OUT.PRINTLN (x) in a class, and then use the static import method, so that the printing does not have to write so long.

Import static net.mingview.util.print.*; All methods in the Print class are imported statically.

3.2 Using Java Operators

3.3 Priority level

3.4 Assigning values

Underlying type: is a change in value

Object type: is a reference change

3.4.1 The alias problem in a method call

The object type parameter of the incoming method will have an alias, which refers to the reference.

3.5 Arithmetic operators

The arithmetic operators in Java have + 、-、 *,/,%, + =,-=, *=,/=,%=

3.5.11-Yuan plus minus operator

Unary plus minus sign and two plus minus sign use the same symbol, the compiler will automatically judge.

x = (-a);

x = A * (-B);

Parentheses are generally used to make the look more obvious. The unary Plus is just to correspond to a unary minus, and the only effect is to convert the smaller type to int.

3.6 Auto Increment and decrement

' + + ' and '-' have 2 usages, prefixes and suffixes.

The prefix indicates that the re-generated value is calculated first, and the suffix indicates that the value is calculated.

3.7 Relational operators

The operator that can produce a Boolean result is a relational operator.

Includes >, <, >=, <=, = =,! =

Equivalence of 3.7.1 test objects

= = and! = Compares whether the object pointed to by the reference is the same, or true, otherwise false.

The Equals () method can be used by replication to compare content.

3.8 Logical operators

&& and, | | Or,! A Boolean value can not be generated

Java Programming Ideas: 3rd Chapter operator

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.