Boolean represents just two values, i.e. True or False.
A bool Data Type can accept only true or false.
public class MyApplication { public static void main(String[] args) { boolean x = true; boolean y = false; System.out.println(x); System.out.println(y); } }
So, in the above code, we have created a variable named x of Boolean data type and initialised it with value True.
boolean x = true;
And created one more variable called y of Boolean data type and initialised it with value False.
boolean y = false;
But if we want to initialise a Boolean type variable with anything other than true/false, it would end up with an error.