Search code examples
javaandroidbitwise-operatorsones-complement

What does ~ mean in Java?


I found a new symbol in a Java project and want to know what does it mean?

systemUiVisibility & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

What does ~ mean in this context?


Solution

  • The unary bitwise complement operator "~" inverts a bit pattern; it can be applied to any of the integral types, making every "0" a "1" and every "1" a "0".


    For example, a byte contains 8 bits; applying this operator to a value whose bit pattern is "00000000" would change its pattern to "11111111".


    More information is here and here.