What does & # 8594; mean in java?

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.

+7
java syntax for-loop
source share
6 answers

--> not a new operator.

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 
+11
source share

i --> 0 means i --> 0 , i decrememnted and the previous value of i compared to 0 .

+6
source share

--> not an operator. This is just cocatination -- and > .

So when you write

i-->0 means comparing the value of i , and then decreasing it.

So, for better readability it can be written as

 for (int i = 99; (i--)> 0;) { 
+4
source share

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.

+3
source share

i-- > 0

i-- - post decrement

> 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.

+2
source share

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.

+2
source share

All Articles