Gilbert
40
Q:

else if java

System.out.println("How many sattelites does JUPITER have ??");
		C = scan.nextInt();
		
		if (C == 79)
		{
			System.out.println("Congrats ! You got the Third  Question Right :)");
			points = points + 1;
		}
		
		else if (C != 79)
		{
			System.out.println("Sorry but your answer is wrong :(");
		}
3
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
}
10
if statement executes a set of statements if condition is true.

Syntax:

if(condition)
{
   // if condition is true;
}
3
else if statement is used to specify new condition if first condition is false.
Syntax:

if(condition1)
{
   // execute if condition1 is true
}
else if (condition2)
{
   // execute if condition2 is true
}
else if (condition3)
{
   // execute if condition3 is true
}
else
{
   // execute if conditions 1, 2 and 3 becomes false
}
1
int a=10;
if(a>5){
// block of code to be executed if the condition in true
}
else{
// block of code to be excuted if the condition in false
}
4
if(x == 1 && y == 2){
  println("x = 1 and y = 2");
}
3
let let x: number = 10, y = 20;

if (x > y) 
{
    console.log('x is greater than y.');
} 
else
{
    console.log('x is less than or equal to y.'); //This will be executed
}
1
int x = 3;

if (x<=3){
	System.out.println("Hello World");
}

else {
	System.out.println("Bye World");
}
1
int x = 3;

if (x == 3) {
  // block of code to be executed if the condition is true
}
8
if (condition) {
  // block of code to be executed if the condition is true
}
1

New to Communities?

Join the community