In java programming we use primitive type call Boolean. It can only return two possible value that is true and false. In programming some time it’s important to create an output that can use to control other operations, Boolean is help us on it.
Now let’s write a program
Now let’s write a program
public class useBooleans {
public static void main(String args[])
{
boolean a;
a=true;//set a as true
System.out.println("a is "+a);
a=false;//set a as false
System.out.println("a is "+a);
}
}
Let’s see the output of this programpublic static void main(String args[])
{
boolean a;
a=true;//set a as true
System.out.println("a is "+a);
a=false;//set a as false
System.out.println("a is "+a);
}
}
a is true
a is false
As we can see that when we set the value of variable a as ‘true’ it returns a as ‘true’. Same happen for ‘false’. Now if we are use this value in programming with conditional operators like ‘if-else’ or ‘while’ then it makes proper use of Boolean Variables. Let’s write a programa is false
public class useBooleans {
public static void main(String args[])
{
boolean a;
a=true;//set a as true
if(a)
{
System.out.println("This is executed when a "+a);
}
a=false;//set a as false
if(a)
{
System.out.println("This is executed when a "+a);
}
}
}
Let’s see the output of this programpublic static void main(String args[])
{
boolean a;
a=true;//set a as true
if(a)
{
System.out.println("This is executed when a "+a);
}
a=false;//set a as false
if(a)
{
System.out.println("This is executed when a "+a);
}
}
}
This is executed when a true
In above program we can see that ‘if’ is executed when variable a is true. In programming relational operators return Boolean variable. For example we can write a program
public class useBooleans {
public static void main(String args[])
{
int a=5,b=9;
System.out.println("a>b is "+(a>b));
}
}
Let’s see the output of above programpublic static void main(String args[])
{
int a=5,b=9;
System.out.println("a>b is "+(a>b));
}
}
a>b is false
in above program we can see that (a>b) is printed as false.

Nice way of expressing your ideas with us.thanks for sharing with us and please add more information's.
ReplyDeleteJAVA Training in Chennai
JAVA Course in Chennai
Digital Marketing Course in Chennai
Python Training in Chennai
Big data training in chennai
Selenium Training in Chennai
JAVA training in Annanagar
Java courses in chennai anna nagar
"wow
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery"
"Thanks for sharing such a nice info.I hope you will share more information like this. please keep on sharing!
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
"
I really liked your blog article.Really thank you! Really Cool.
ReplyDeleteGo Language online training
Go Language training
Hibernate online training
Hibernate training
Hyperion ESS Base online training
Hyperion ESS Base training
Hyperion Fdqm online training
Hyperion Fdqm training
Hyperion Financial Management online training
Hyperion Financial Management training
Hyperion online training
Nice Post . Keep sharing java training in pune
ReplyDeleteI really liked your blog article.Really thank you! Really Cool.Web Development course in Kolhapur
ReplyDeleteThanks for the post. It was worth reading.
ReplyDeletealso, check Java Training in Pune