java中的“>>”和“>>>”运算符是什么?

What is the ">>" and ">>>" operator in java?

您好,我想知道是否有人可以帮助我解决一些我在网上几乎找不到的问题。 我正在查看一些具有以下语句的代码:

int mainInt = 10>>> 5;

有人知道这个 >> 运算符是什么吗?

例如 10 >> 1 等于 5 20 >>> 等于 3

谢谢

>>arithmetic right-shift operator.

>>>logical right-shift operator.

第一个保留操作数的符号。第二种在最高有效位位置插入零,通常应用于无符号数。

已回答:Double Greater Than Sign (>>) in Java?

The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.

你可以阅读它here