This is in no way the official description of booleans, this is my description based on personal experience. Booleans to me are basically an on off switch in code. That's how they perform so that's how I look at them. Most of the time they are used to control if statements, but that's a whole different tutorial. Booleans have 3 states that it can be in. True, false, and null. True and false are self explanatory. Null means it is undecided, Basically in between both true and false.
How To Setup/Use:
Booleans are the easiest things to use but can make things a lot easier.
To start of a boolean you first need to declare it:
Those are the three ways you can declare a boolean. First one is undecided or null, the second one is making it false right off the bat and the third one is making it true.
Now say we want to change the boolean from true to false.(The IF is there to simply help understand, pay attention to the boolean though.)
In this code, when the program starts the boolean is true, but when that button is clicked it turns it false.
That's it on booleans, when we get to more tutorials you will be able to see how they work and function, but being that you don't know any java its kind of hard to explain how they work without showing you other code to get you confused. See you next tutorial!
Booleans are the easiest things to use but can make things a lot easier.
To start of a boolean you first need to declare it:
PHP:
public boolean name;
PHP:
public boolean name = false;
PHP:
public boolean name = true;
Now say we want to change the boolean from true to false.(The IF is there to simply help understand, pay attention to the boolean though.)
PHP:
public boolean name = true;
if(button is pressed){
name = false;
}
That's it on booleans, when we get to more tutorials you will be able to see how they work and function, but being that you don't know any java its kind of hard to explain how they work without showing you other code to get you confused. See you next tutorial!