Java Unary Operator Boolean Inverting Example


Program
public class UnaryOperator{ public static void main(String args[]){ boolean x=true; boolean y=false; System.out.println(!x);//1 //(This will invert x true value to false) System.out.println(!y); //(This will invert y false value to true) }}
Input
Output