What does "<<" mean in Java??

rebolli

New Member
Messages
3
Reaction score
0
Points
0
Hello,

Could anyone tell me what the syntax "<<" does in java?
For example, if I do the operation 1 << 4 I'll get the output 16. How does that work? :confused:

Couldn't find this on google cause the characters "<<" are ignored.. :(
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
It's a bitwise left shift. In your example, you start out with a one, which can be represented in binary as: 00000000 00000001

then you tell the computer to shift the bits leftwards four times, yielding this binary number: 00000000 00010000

10000 in binary is 16 in decimal.
 
Top