если еще 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
}
// Traditional way
if (20 > 18) {
System.out.println("20 is greater than 18");
}
// "efficient" way
int time = 20;
String result = (time < 18) ? "Good day." : "Good evening.";
System.out.println(result);