for (int i = 99; i --> 0;) { System.out.println(i); }
It works on the code and has exactly the same result
for (int i = 99; i >= 0; i--) { System.out.println(i); }
What does the "->" syntax mean initially in Java? Since nearly accessible search engines prohibit special characters, I cannot find the answer.
-->
This is just a conjunction of operators -- and > .
--
>
First you compare and then decrease the variable.
I.e
i --> 0
becomes effective
i > 0; //Compare i--; //and decrement
i --> 0 means i --> 0 , i decrememnted and the previous value of i compared to 0 .
i
0
--> not an operator. This is just cocatination -- and > .
So when you write
i-->0 means comparing the value of i , and then decreasing it.
i-->0
So, for better readability it can be written as
for (int i = 99; (i--)> 0;) {
Please note that the increment / decrement location did not appear. Therefore, it reduces i by 1 and compares it with 0.
Comparison check: i greater than 0 after decrement execution.
i-- > 0
i-- - post decrement
i--
> more than
for (initializatin; boolean expression;updation){ }
So, you did the initialization, but you checked the logical expression and updated in one step to make it work.
there is no operator --> its just i--> 0 at first it will do post-decrements. then it will check the status and compare with 0 , whether it is more.
Remember that the value I will not be changed during the comparison (i will be 1) after the comparison, it will reduce the value (now I will be 0) and print it.