Login Register






[Java | Basic | 1] Booleans [Deviation] filter_list
Author
Message
[Java | Basic | 1] Booleans [Deviation] #1
Java Tutorial - Booleans
[Image: 444qZ.png]
By Bane, brought to you by Deviation

Description:
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:
PHP Code:
public boolean name;
PHP Code:
public boolean name = false;
PHP Code:
public boolean name = true;
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.)
PHP Code:
public boolean name = true; if(button is pressed){ name = false; }
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!

[Image: signature.png]

Reply

RE: [Java | Basic | 1] Booleans #2
Pretty nice, Bane.

I would love to get into Java myself.
  • Contact Paradox or Uzi for Admin related duties
  • Contact Operate for Staff queries
  • PM me if you need any help.

Reply

RE: [Java | Basic | 1] Booleans [Deviation] #3
God that PHP BBCode is horrific. We need to do something about that...

Reply