Home > Java > javaTutorial > body text

What does +i+ mean in java

下次还敢
Release: 2024-04-29 00:12:13
Original
920 people have browsed it

In Java, " i " is a compound assignment operator that increases the value of variable i by 1 and then returns the updated value. It is equivalent to "i = 1", which increases the value of variable i by 1 and updates its reference.

What does +i+ mean in java

What does i mean in Java

In Java, " i" is A compound assignment operator. It increases the value of variable i by 1 and returns the updated value.

Specifically, the compound assignment operators in Java are as follows:

  • = Additive assignment
  • -= Subtraction assignment
  • *= Multiplication assignment
  • /= Division assignment
  • %= Take Remainder assignment
  • <<= Left shift assignment
  • >>= Right shift assignment
  • &= and assignment
  • |= or assignment
  • ^= XOR assignment

Among them, " i" is equivalent to "i = 1". It increases the value of variable i by 1 and then assigns the updated value to i.

Example:

<code class="java">int i = 10;
i += 1; // 等价于 i = i + 1
System.out.println(i); // 输出:11

i = i + 1; // 传统的加法赋值
System.out.println(i); // 输出:12</code>
Copy after login

In the first example, use the compound assignment operator " i" to increase the value of i by 1, and updated the reference of i. In the second example, using traditional additive assignment, a new value is created and then assigned to i.

The above is the detailed content of What does +i+ mean in java. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!