Search code examples
javasyntaxoperatorsspecial-characters

Java: What does ~ mean


In this Java source code I have this line:

if ((modifiers & ~KeyEvent.SHIFT_MASK) != 0) ....

What does the tilde ~ mean?


Solution

  • The Tilde (~) performs a bitwise complement of a numerical value in Java.

    See: Bitwise complement (~): inverts ones and zeroes in a number