Wenn sonst Java
if (condition) {
// statement
} else if(condition){
// statement
}else{
// statement
}
CodePadding
if (condition) {
// statement
} else if(condition){
// statement
}else{
// statement
}
class IfStatement {
public static void main(String[] args) {
int number = 10;
// checks if number is less than 0
if (number < 0) {
System.out.println("The number is negative.");
}
System.out.println("Statement outside if block");
}
}
int hi = 30
if (hi < 5) {
System.out.println("ok");
}
else {
System.out.println("no");
}
// A basic simple of an if statement
var apples = 10;
var bananas = 11;
if (apples > bananas) {
print("Too much apples")
} else {
print("Too much bananas")
}
if (condition) {
// codes in if block
}
else {
// codes in else block
}
if (condition1) {
// codes
}
else if(condition2) {
// codes
}
else if (condition3) {
// codes
}
.
.
else {
// codes
}