Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is ++== in Java?

Tags:

java

operators

  1. Searched this site, found no reference.
  2. Test code:

    int[] test = {0, 1, 2, 3};
    System.out.println("test1[3] ++== 0 is " + (test[3] ++== 0));
    
  3. Result:

test1[3] ++== 0 is false

So it must be some sort of logical operator but I have not been able to find any documentation. Searching the Internet yielded no reference.

Please help? Thanks in advance.

like image 385
N2Vo Avatar asked Dec 10 '22 03:12

N2Vo


2 Answers

The way the text is presented looks like it would be a special case ++==, but in fact you should read it as follows:

test[3]++ == 0

Basically, the result of test[3]++ will be compared (i.e ==) with 0.

And this basically reads as (test[3]=3) == 0, which is false.

The ++ is a postfix operator which is shortcut for value = value + 1.

The == is a comparison between two values.

The text is just badly formatted, that's all.

like image 50
Andrei Sfat Avatar answered Jan 02 '23 01:01

Andrei Sfat


++ and == are two independent operators. ++ is post-incrementing the value of test[3], then that is being compared to 0.

like image 27
Paul Whalen Avatar answered Jan 02 '23 02:01

Paul Whalen