加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

我怎样才能使用java运算符“| “在科特林?

发布时间:2020-12-15 00:39:17 所属栏目:Java 来源:网络整理
导读:我该如何使用此运算符? int a = 5 | 10;int b = 5 10; 它可以在Java中使用,但在Kotlin中看不到它. 解决方法 您已为它们命名了功能. 直接从Kotlin docs As of bitwise operations,there’re no special characters for them,but just named functions that c
我该如何使用此运算符?
int a = 5 | 10;
int b = 5 & 10;

它可以在Java中使用,但在Kotlin中看不到它.

解决方法

您已为它们命名了功能.

直接从Kotlin docs

As of bitwise operations,there’re no special characters for them,but just named functions that can be called in infix form.

例如:

val x = (1 shl 2) and 0x000FF000

Here is the complete list of bitwise operations (available for Int and Long only):

shl(bits) – signed shift left (Java's <<)
shr(bits) – signed shift right (Java's >>)
ushr(bits) – unsigned shift right (Java's >>>)
and(bits) – bitwise and
or(bits) – bitwise or
xor(bits) – bitwise xor
inv() – bitwise inversion

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读