Rakesh Rakesh - 2 months ago 7x
Java Question

How this binary OR (|=) gets executed in Java?

Found this on HikariCP but unable to understand how the code in the attached will be run ? enter image description here


The value of _forceClose becomes _forceClose | (sqlState.startsWith("08") | SQL_ERRORS.contains(sqlState)). |= is just a bitwise OR, so x |= y vs x = x | y. It works the same as x += y vs x = x + y.

Java documentation on bitwise operators.