Does C++ and Java actually have an else if statement or is it just an else statement with a nested if statement. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does C++ and Java actually have an else if statement or is it just an else statement with a nested if statement.

As it is possible to use statements that only require 1 statement without curly braces I thought that this: if (...) { ... } else if (...) { ... } else { ... } would actually be this: if (...) { ... } else { if (...) { ... } else { ... } } and no separate else if statements actually existed. Scanner sc = new Scanner(System.in); System.out.println("How is it?"); System.out.println(sc.nextBoolean());

1st Sep 2019, 3:09 PM
Seb TheS
Seb TheS - avatar
1 Answer
+ 4
You're correct, there is no such thing like elif statement in both Java and C++, and yes, the else if is actually a nested if statement
1st Sep 2019, 3:46 PM
Agent_I
Agent_I - avatar