13

I know that >> (two times greater than) is shifting , but what does >>> do exactly ?

    System.out.println(16>>>2);  // OK

    System.out.println(8>>>2);   // OK 

    System.out.println(8>>>2);  // OK 

    System.out.println(8<<<2);  // not OK
JAN
  • 21,236
  • 66
  • 181
  • 318

2 Answers2

16

>>> Shift right zero fill operator.
The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.

Rakesh KR
  • 6,357
  • 5
  • 40
  • 55
  • 3
    I know this is a stupid question, but do you have a simple example of where you would apply this? – timon_the_destroyer Nov 18 '16 at 12:42
  • 2
    You can use this to generate hashCodes. For Example in the Point class of org.opencv.core they use this line of code in the generation of the hashcode: result = prime * result + (int) (temp ^ (temp >>> 32)); – David Nov 23 '16 at 11:09
  • 2
    An excellent example as to where it is really applied in JDK: https://research.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html?m=1 – Vivek Sethi Aug 02 '17 at 08:09
  • 1
    @VivekSethi I came across `>>>` during my reading of the same article which led me searching for it here. Boom, the programming full circle. – Acy Jul 17 '22 at 15:57
3

>>> is valid operator <<< in not valid operator in java if try to use this it give

Syntax error on token "<", delete this token

>>> :Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.

More information:

why is 1>>32 == 1?

Community
  • 1
  • 1
Sitansu
  • 3,225
  • 8
  • 34
  • 61