How to use the java self-increment and self-subtraction operators
This article mainly introduces the relevant knowledge of how to use the java self-increasing and self-subtracting operators, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on how to use the java self-increasing and self-subtracting operators. Let's take a look.
1. Nasty + adds the current value of the variable n by 1 and subtracts the value of the variable n by 1.
2. These operators change the value of the variable and cannot be applied to the numerical value itself.
3. In the expression, n means self-increment and then assignment, and n means assignment and then self-increment.
Example
/ / mixed with print operation, int num2 = 20 impact / mixed, first + +, the variable immediately becomes 21, and then print the result 21System.out.println (+ + num2); / / 21System.out.println (num2); / / 21System.out.println ("="); int num3=30;// mixed use, followed by + +, first use the original 30 of the variable, and then let the variable + 1 get 31System.out.println (num3++); / / 30System.out.println (num3) / / 31System.out.println ("="); int num4 = 40 num4 / mixed with assignment operation int result1 =-- num4;//, the former--, immediately-1 becomes 39, and then the result 39 is handed over to the result1 variable System.out.println (result1); / / 39System.out.println (num4); / / 39System.out.println ("="); int num5 = 50 / / mixed use, after-- first give the original number 50 to result2, and then I change-1 to 49int result2 = num5--;System.out.println (result2); / / 50System.out.println (num5); / / 49System.out.println ("="); int x = 10X int y = 20bot result3 11mm 20mm 31int result3 = + + x + y Mustang system. Out.println (result3); / / 31System.out.println (x); / / 11System.out.println (y) / / 19Universe / wrong spelling / 19 / 19 / 19 / 19 / 19. Constants cannot use + + or--} this article on "how to use the java self-increment and self-subtraction operators" ends here, thank you for reading! I believe you all have a certain understanding of the knowledge of "how to use java self-increasing and self-decreasing operators". If you want to learn more, you are welcome to follow the industry information channel.