>" 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".">

Home  >  Article  >  Java  >  What is ">>" in java

What is ">>" in java

王林
王林Original
2019-11-22 15:28:2110805browse

What is >" 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:

What is >> in java

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn