>" in the Java programming language represents the right shift operator in the shift operator. The general format is: "value>>num", where "num" represents the specified value to be shifted, " value" represents the number of bits to move. For example: "num>>1", this code means: "num" divided by "2"."/> >" in java-Javagetting Started-php.cn"> >" in the Java programming language represents the right shift operator in the shift operator. The general format is: "value>>num", where "num" represents the specified value to be shifted, " value" represents the number of bits to move. For example: "num>>1", this code means: "num" divided by "2".">
>" in java" >
There are three shift operators in java
>> : : Right shift operator, num >> 1, which is equivalent to dividing num by 2
Let’s take a look at how these shift operations are used.
package com.b510.test; public class Test { public static void main(String[] args) { int number = 10; //原始数二进制 printInfo(number); number = number << 1; //左移一位 printInfo(number); number = number >> 1; //右移一位 printInfo(number); } private static void printInfo(int num){ System.out.println(Integer.toBinaryString(num)); } }
Running results:
1010 10100 1010
Let’s align the above results:
Recommended tutorial: java Quick Start
The above is the detailed content of What is ">>" in java. For more information, please follow other related articles on the PHP Chinese website!