The logical NOT operator ! flips a boolean value. true becomes false, and false becomes true.
boolean isLoggedIn = false;
if (!isLoggedIn) {
System.out.println("Please log in.");
}
!isLoggedIn reads as "not logged in". This is easier to read than writing isLoggedIn == false, which does the same thing but takes longer to parse visually.
You can also apply ! to expressions in parentheses. !(age > 18) returns true when age is or less. Parentheses matter here because ! has higher precedence than >.