What does << mean in Java?

前端 未结 8 1129
面向向阳花
面向向阳花 2020-12-06 10:08

I can\'t find out what << means in Java because I can\'t search for it on Google - I am absolutely lost!

The code in question is:

         


        
8条回答
  •  日久生厌
    2020-12-06 10:25

    It is the left shift operator. Here's some more information on shift operators from the Java Tutorial.

    In your example code the three integer values: red, green and blue will typically have values 0-255. Hence, it is possible to combine these values and represent them as a single integer by shifting the red value by 16 bits, shifting the green value by 8 bits and then performing a bitwise-OR operation to combine the values.

提交回复
热议问题