Conditions in Java: The if command
The most important conditions in Java with the if command. If you are using Java or have no experience you should, can you first of all, the Java-Basics , please click here. Practical code examples can be found incidentally in the gallery at the end of the article.
- The handling of this command is relatively easy. First, you write "if (condition) {". Instead of "condition" and write the condition.
- If you want to check whether a value is smaller than the other, the "=" check whether a value is greater than or equal to another. Finally, you can check with "==" if a value is not equal to another, or with "!=" if he does not do this.
- An if command could look like this: "if (7 >= 5) {". This condition would apply. After the curly brace write the commands to be executed if the condition is true. Do not forget, however, at the end of a closing curly bracket to add.
- If you do not want to even consider the case that the condition is true, you can add at the end of the command, "else {". The commands within this command will not be executed if the condition is true. Also do not forget the bracket.

Conditions in Java: The if command
Java: tips for if-commands
Thus, the programming is simpler, there are a few Tricks on how you can if commands in a more targeted way to apply.
- An if-Statement, you can also add inside of other if-Statements. This is called "Nested-if-Statements".
- In addition, there is the "else-if-Statement". Here you can write a normal if command. Then you write "else if(...) {" and at the end of the else command. Here, you can have multiple single conditions, to execute different commands successively by testing.
- Several conditions can be linked with"&&". An example of this is the command "if (a is < 5 && b >= 17) {". Similarly, there is also an Or-link. The command "if (a < 5 || b >= 17) {" is true, for example, if a is less than 5 or b is greater than or equal to 17.

Java: tips for if-commands
Java: switch commands
The switch command tests whether the value of a Variable is equal to a certain value. Each value is called here "case". We have defined at this point with the command "int day = 3;" is a Variable. Now we want to insert a switch command.
- First you write the command "switch (day) {".
- Then it is checked with the command "case 1:", if "day" has the value 1. If that is the case, run all of the commands are case-command (indented),. If you want to, you can add to these commands, the command "break;", which causes the switch command is terminated as soon as the in the case-command condition is true.
- Now you can add as many case commands as you like.
- If no condition is true, the commands, the (indented) under "default:", run.

Java: switch commands
Loops in Java: The while loop
The simplest loop in Java is the while loop.
- This always starts with a command, such as "while (...) {". In the parentheses you write a condition. In the curly brackets are the commands that should be executed to come.
- An example of a while loop is "int x = 3;" ⮩ "while (x > 0) {" ⮩ "System.out.println(x);" ⮩ "x--;" ⮩ "}". This loop is (sequentially) the values 3, 2 and 1.
- If the condition, the loop is in the while, is not true, the program executes the commands after the loop.

The while loop
Loop The for-loop program:
In addition to the while loop in Java the for loop. The Syntax of this loop is "for (initialization; condition; increment/decrement) {".
- Instead of "initialization;" you can, for example, "int x = 1;". Instead of "condition" and write a condition, such as, for example, "x
