So, First I would assume you have basic understanding of variables, for this tutorial we are going to be using an integer as-well as a boolean.
So, First we are going to declare our variables.
Code:
private boolean isBored = true;
private int postCount = 0;
Next, we are going to write our if-statement.
Code:
if(isBored)
{
postCount++;
}
The above code reads as following, (If the boolean variable isBored is set to true, perform the actions below(Increase postCount by one)
Here is another way to do the same exact thing.
Code:
if(isBored == true)
{
postCount++;
}
This also does the same thing, however brackets are not needed because there is only one line of code following the if() statement
Code:
if(isBored)
postCount++;
This also does the same thing, once again.
Code:
if(isBored == true)
postCount++;
Now, the next example does more than one thing inside of the if() statement, so brackets are required
Code:
if(isBored)
{
postCount++;
isBored = false;
}
The above code checks to see if the value of isBored is set to true, if it is, than it will increase my post count by one, and set the isBored boolean to equal false.
If you couldn't tell, I was bored.
This, Technically is a tutorial.
Da..da.d.ad.a.... Dats all folkz