管道角色在Java方法调用中做了什么? [英] What does the pipe character do in a Java method call?
本文介绍了管道角色在Java方法调用中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在Java程序中看到了方法调用中使用的管道字符。
I've seen the pipe character used in method calls in Java programs.
例如:
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
。
When I run this, I simply get 7
.
有人可以解释管道在方法调用中的作用以及如何正确使用它吗?
Can someone explain what the pipe does in the method call and how to use it properly?
推荐答案
3中的管道2
是按位包含OR 运算符,返回3在你的情况下( 11 | 10 == 11
二进制)。
The pipe in 3 | 2
is the bitwise inclusive OR operator, which returns 3 in your case (11 | 10 == 11
in binary).
这篇关于管道角色在Java方法调用中做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文