+ 3

What is the use of Boolean in Java?

14th Aug 2019, 4:26 PM
Rainbow Rose
Rainbow Rose - avatar
3 Antworten
+ 2
It is a datatype to check informations, that can only have 2 different values. You can get booleans, when you compare values. 5 < 7 --> 5 is less than 7 --> true 6 == 4 --> 6 is equal to 4 --> false 3 >= 3 --> 3 is great than or equal to 3 --> true This is very close to real life conditions. In real lif you could say "If I have atleast 300€, I can buy a new bicycle.". In programming world, it would be something like this: int money = 400; if (money >= 300) { System.out.println("I can buy a new bicycle."); } "I can buy a new bicycle." would be printed if money >= 300 was true, otherwise it would be skipped.
14th Aug 2019, 5:13 PM
Seb TheS
Seb TheS - avatar
+ 3
True or false
14th Aug 2019, 4:28 PM
Bug Slayer
+ 3
Hmm, you know, boolean is a kind of logic which is used in languages like java. You may know boolean algebra. But, in java, boolean is used as logic to determine and compare where the given inputs are either true or false.
14th Aug 2019, 4:53 PM
NightFox
NightFox - avatar