I am confused about boolean variables. What is the use of boolean variables? We can use short variable (as a flag) for the required purpose then what edge does boolean variables gives us?
if(var == 1)
Right now you are using a boolean operator (the double = sign). The result of the following equation is true of false. '
The use is this (in pseudocode):
note: Pseudo code is English, written in a more code like form, just to make sense. That of course will not compile.
boolean isAuthenticated = false;
if (passWordIsCorrect) isAuthenticated = true;
else isAuthenticated = false;
if (isAuthenticated) allowToSeeSecretData;
So its slower in that case. If I use boolean variable, it will be faster... Is this what you mean?
It's more of a convenience to further abstraction, fundamental to OOP.
Originally Posted by ravian