What is a name | operator in java
In java 7, we can track multiple exceptions at a time like
try {
Class a = Class.forName("wrongClassName");
Object instance = a.newInstance();
} catch (ClassNotFoundException | IllegalAccessException |
InstantiationException ex) {
System.out.println("Failed to create instance");
}
Is this bitwise inclusive OR? As far as I know in java, bitwise operators are used to compare binaries. If it is not, then how does java differentiate this operator with Bitwise Inclusive OR?
Just want to know the name of the operator used here and this operator exists before java 7.
Any answer is appreciated. Thank you.
source to share
It is valid as of Java 7 and I call it a pipe.
The catch block itself is called a multi-catch block.
This operator is a bitwise or multi-user operator, depending on the context in which it is used. As in (1 + 1)
, the operator +
is the addition operator, and in "hello" + "world"
the + operator is the concatenation.
source to share
docs said:
The catch clause specifies the types of exceptions that the block can handle, and each type of exception is separated by a vertical bar (|).
This operator is used as a bitwise inclusive OR before Java 7.
source to share