Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the java operator

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use the java operator, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Four operators

The plus sign "+" in the four operations has three common uses:

1. For numerical values, that is addition.

2. For the character char type, char is promoted to int before calculation, and then calculated. Comparison of char type characters with int type numbers: ASCII,Unicode

3. For the string String (the first letter is uppercase, not a keyword), the plus sign represents the concatenation operation. When any data type is concatenated with a string, the result becomes a string

Self-increasing operator: +

Self-subtraction operator:--

Basic meaning: let a variable increase a number, or let a variable drop a number 1

Use format: write before or after the variable name.

For example:

+ + num, or num++

How to use it:

1. Use it alone: do not mix with any other operations, but become a step independently.

2. mixed use; mixed with other operations, such as with assignment, or with print operation, etc.

Usage differences:

1. When used alone, there is no difference between pre-+ and post-+. That is, the two have exactly the same effect.

2. There is a big difference in mixed use.

[note]

A: if it's [pre-+], then the variable [immediately + 1], and then take the result and use it. [add first and use later]

B: if it is post + +, then use the original value first, and then let the variable + 1. [use first and then add]

Note:

Only variables can use the self-increment and self-subtraction operators. Constants cannot be changed, so they cannot be used.

Assignment operator

The assignment operators are divided into:

The basic assignment operator is an equal sign "=", which means to hand over the data on the right to the variable on the left.

Int a = 30

Compound assignment operator

+ = aura 3 is equivalent to aura 3 color = * / =% =

Note:

Only variables can use assignment operators, and constants cannot be assigned.

The compound assignment operator implies a cast.

Byte num = 30 intSystem.out.println num + = 5 Trachampact num = num + 5//num = byte + int//num = int + int//num = int//num = (byte) intSystem.out.println (num); / / 35

Comparison operator

Greater than: >

Less than: =

Less than or equal to:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report