I have looked on the oracle website, but that seems to advanced for me, please can someone give me a basic run down on what the >> operator is for in java? and maybe a basic example would be nice.
4 Answers
>> is right bitwise shift. For example, 5 >> 1 is 2, because 5 is 101 in binary, and that's shifted right to get 10.
It's (mostly) equivalent to "divided by two to the", although it's not quite equivalent for negative numbers.
4 Comments
Shaun Wild
Perfect answer, thanks. why do people still vote my question down, isn't this site for asking questions?
Louis Wasserman
I don't know, and I don't think they should be. I'd upvote your question if I wasn't out of upvotes for the day.
DNA
Not my downvote, but it's probably because googling "Java operators" and looking through the first few results will provide what you asked for (including examples)
Shaun Wild
Good point, but like i said in the question the "bitwise operator" wasn't good enough for me, i wanted a simple explanation and a basic exmaple..
This is signed right shift operator. You can look for docs here: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html
Comments
Please find example here: http://www.roseindia.net/java/master-java/java-right-shift.shtml