加法赋值运算符_Java中的+ =加法赋值运算符是什么?

加法赋值运算符

It’s the Addition assignment operator. Let’s understand the += operator in Java and learn to use it for our day to day programming.

它是加法赋值运算符。 让我们了解Java中的+ =运算符,并学习如何将其用于日常编程。

x += y in Java is the same as x = x + y.

Java中的x + = yx = x + y相同

It is a compound assignment operator. Most commonly used for incrementing the value of a variable since x++ only increments the value by one.

它是一个复合赋值运算符。 由于x ++仅将值增加1,因此最常用于递增变量的值。

使用+ =运算符递增值 (Incrementing Values With the += Operator)

This code will increase the value of a by 2. Let’s see the examples:

这段代码会将a的值增加2。让我们看一下示例:


int a = 1;
a+=2;
System.out.println(a);

你可能感兴趣的:(字符串,java,python,编程语言,算法)