gpt4 book ai didi

java - 管道字符在 Java 方法调用中起什么作用?

转载 作者:太空狗 更新时间:2023-10-29 23:02:59 26 4
gpt4 key购买 nike

我见过 Java 程序中方法调用中使用的管道符。

例如:

public class Testing1 {

public int print(int i1, int i2){
return i1 + i2;
}
public static void main(String[] args){
Testing1 t1 = new Testing1();
int t3 = t1.print(4, 3 | 2);
System.out.println(t3);
}
}

当我运行它时,我只得到 7

谁能解释管道在方法调用中的作用以及如何正确使用它?

最佳答案

3 中的管道 | 2bitwise inclusive OR运算符,在您的情况下返回 3(11 | 10 == 11 二进制)。

关于java - 管道字符在 Java 方法调用中起什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16443028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com