# else-if

You can combine several conditions together using else if.

if (boolean expression 1)
{
  // if boolean expression 1 evaluates to True
}
else if (boolean expression 2)
{
  // if boolean expression 2 evaluates to True
}
1
2
3
4
5
6
7
8

You can also use else after the last else-if.

if (boolean expression 1)
{
  // if boolean expression 1 evaluates to True
}
else if (boolean expression 2)
{
  // if boolean expression 2 evaluates to True
}
else
{
  // if boolean expression 2 evaluates to False
}
1
2
3
4
5
6
7
8
9
10
11
12
Last Updated: May 1, 2020, 3:31 PM