Rakesh Rakesh - 1 year ago 62
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download