One of the most basic uses of computers is to perform mathematical operations, and as a computer language, Java also provides a rich set of operators to manipulate variables. We can divide the operators into the following groups:
Arithmetic
overloaded operators and conversions--Self-increment/self-decrement operatorIntroduction:Self-increment, the decrement operator is often implemented by classes such as iterators that provide pointers-like behavior to access elements in a sequence.
Like C, Java provides a rich shortcut for computing. These shortcuts can make the code more refreshing, easier to input, and easier for readers to read.Two good shortcuts are the increment and decrement operators (often referred to as "AutoIncrement"
The self-increment operator "+ +" and the decrement operator "--" contain two versions respectively. That is, operator pre-form (such as ++x) and operator post-form (such as x + +), the two operations are not the same. Therefore, when we overload
The self-increment "+ +" and "subtract"--"are unary operators, and both the pre-and post-form can be overloaded. Take a look at the following example:#include #includeusing namespacestd;classstopwatch{//StopwatchPrivate: intMin//minutes intSec/
In addition to this +-*/% of these 5 arithmetic operators there are actually 2 + +-These two can also belong to the arithmetic operator. He is the self-increment of the decrement operation, for example: int i = 10; i++; I--or ++i-I but these 2 are
The following code:public class Example025 {public static void main (string[] args) {int ape = 100;int it = 100;int ape_it = 100;for (int i = 0; I Output Result:Ape = 0it = 100ape_it = 0Cause Analysis: There should be no objection to the ape's
Look at the operator overloads of C #, and find that they are not the same as C + +. Just been in the C # self-increment operator pit, now to share.First define a class class A { publicint i; Public A (int i) {
Increment is divided into "before increment": ++i, the operation is completed to get the value. "After increment": i + +; The value is obtained before the operation.public class AutoInc () {static void Prt (String s) {System.out.println (s);}public
The implicit type conversion rules and the increment/decrement operators for strings in PHP have been blurred before, and are summarized today.One, implicit conversionImplicit type conversion rules for binary arithmetic operators
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.