Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is --> symbol in Java? [duplicate]

Tags:

java

operators

Recently, I came across a code where --> was used.

example:

int a = 5;
while(a-->0){
    //do something 'a' times
}

Is (a-->0) equivalent to (a-- > 0) or simply, ((a=a-1) > 0)?

If not, I want to know what's that operator called, and are there other similar operators. If so, then where are they mentioned?

Thanks

like image 768
xploreraj Avatar asked Feb 07 '23 18:02

xploreraj


1 Answers

It's two operations. The postfix -- (a = a - 1 but effective on the next line) and a greater than. It's equivalent to something like

while (a > 0) {
    a = a - 1;
like image 135
Elliott Frisch Avatar answered Feb 13 '23 23:02

Elliott Frisch