Possible Duplicate:
What does >> do in java?
What does it do this sign: << ? This is in Java.
For an instance, new CustomPermission(1 << 5, 'M');
Best regards
Possible Duplicate:
What does >> do in java?
What does it do this sign: << ? This is in Java.
For an instance, new CustomPermission(1 << 5, 'M');
Best regards
It's bitshift
http://download.oracle.com/javase/tutorial/java/nutsandbolts/op3.html
Basically it multiplies the left operand by 2 to the power of the right operand
so 1 << 5 is 1 * 2^5
its a bit shift operator
this instruction shifts 00000001 five bits to the left: so it becomes 00100000
It's a signed left shift. What you're calculating there is basically 2^5, as you are shifting 00000001 5 times left, which results in 00100000
The '<<' operator shifts all the bits of the number on the left by the value on the right.
For example 1<<5 will be equal to 32.
This is often used in place of multiplication by a power of 2 as in 1<<5 is equivalent to 1*(2^5) or 1*32
In addition to the other answers, I will also add that bit shifting is commonly used in code which uses bitmasks. So bit 5 in the given code fragment has a specific meaning, which is different to, say bit 3. Using the '<<' operator you can logically combine the different bits to give a combined bitmask.