[英]Why is the bitwise OR operator ( | ) used when catching multiple exceptions in Java?
I've just learned that |
我刚刚得知
|
is used to catch multiple exceptions in the same block; 用于捕获同一块中的多个异常;
|
is the bitwise operator for OR. 是OR的按位运算符。 In this case, is it still used as a bitwise operator or does it have a different meaning when in context?
在这种情况下,它仍然用作按位运算符,还是在上下文中具有不同的含义?
In this case, is it still used as a bitwise operator or does it have a different meaning when in context?
在这种情况下,它仍然用作按位运算符,还是在上下文中具有不同的含义?
It has a different meaning - although it's of the same "flavour" in that it's "if exception X is caught, or exception Y is caught, or exception Z" is caught. 它有不同的含义 - 虽然它具有相同的“味道”,因为它“如果异常X被捕获,或异常Y被捕获,或异常Z”被捕获。
In the JLS section 14.20 the |
在JLS 14.20节的
|
is just included literally in the grammar - it's not the OR operator in this context. 只是字面上包含在语法中 - 在这种情况下它不是OR运算符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.