Conditional Statements - if-then-else
In all language (like English) conditional statements are integral to functionality. If a condition is met then do something. We also have if else statements where if something happens, do something, else do something else. A condition could be if something is
And and Or
for example if we wanted two conditions to be met:
We can bring multiple statements together
Strings
Strings are objects which makes == generally not work. To check equality for Strings you will use the equals method. So if you wanted to say
it should be:
So could block might look like:
Else if statements you can have multiple if statements together-
If you only have one command for your if statement, you do not need brackets. The if statement will do the following command. ie:
|