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. In this case, is it still used as a bitwise operator or does it have a different meaning when in context?

Jon Skeet
people
quotationmark

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.

In the JLS section 14.20 the | is just included literally in the grammar - it's not the OR operator in this context.

people

See more on this question at Stackoverflow