else statement java
int x = 3;
if (x == 3) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
else statement java
int x = 3;
if (x == 3) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
java if else if ladder
import java.io.*;
class GFG {
public static void main(String[] args)
{
// initializing expression
int i = 20;
// condition 1
if (i == 10)
System.out.println("i is 10\n");
// condition 2
else if (i == 15)
System.out.println("i is 15\n");
// condition 3
else if (i == 20)
System.out.println("i is 20\n");
else
System.out.println("i is not present\n");
System.out.println("Outside if-else-if");
}
}
else statement java
int x = 3;
if (x == 3) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
java if else if ladder
import java.io.*;
class GFG {
public static void main(String[] args)
{
// initializing expression
int i = 20;
// condition 1
if (i == 10)
System.out.println("i is 10\n");
// condition 2
else if (i == 15)
System.out.println("i is 15\n");
// condition 3
else if (i == 20)
System.out.println("i is 20\n");
else
System.out.println("i is not present\n");
System.out.println("Outside if-else-if");
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us