“<<" Java中的运算符 [英] "<<" operator in java

查看:124
本文介绍了“<<" Java中的运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

轻松声明来自Java的Character类:

Fallowing statement is from Character class of java:

(1 << Character.PARAGRAPH_SEPARATOR)) >> type

PARAGRAPH_SEPARATOR是一个字节,type是一个整数.

PARAGRAPH_SEPARATOR is a byte and type is an integer.

这句话中的操作员,他们做什么?我该如何以及在何处使用这些运算符?

The operators in this sentence, what do they do? how and where I can use those operators?

以下是预言家 java.lang.字符文档.该类中几乎所有方法都使用这些运算符.

Here is the oracles java.lang.Character doc. Nearly all the methods in the class uses those operators.

推荐答案

它们是位移运算符. <<将位左"(向最高有效位)移位,反之亦然.向左或向右移动 n 位与分别乘以2 n 差不多.

They are bit-shift operators. << shifts the bits "left" (towards the most-significant bit), and vice-versa for >>. Shifting left or right by n bits is pretty much the same as multiplying or dividing, respectively, by 2n.

有关在这种情况下如何使用这些运算符的说明,请参见@axtavt的注释.

See @axtavt's comment for an explanation of how these operators are being used in this context.

这篇关于“&lt;&lt;" Java中的运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆