Indentations in If-Else? I am a beginner at Java and this code example came up in class:
int horsepower = 15;
      if(horsepower &gt; 15)
         if(horsepower &lt;= 20)
            System.out.println(&quot;There is a lot of horsepower&quot;);
      else
          System.out.println(&quot;The car super fast&quot;);

the output is nothing but I can't understand why.
I have 2 questions I would like to clarify:

why did the code under the else statement not get executed?
I understand that without the brackets { }, the if condition can only execute the next statement. In this case, if horsepower variable is 17 instead, will &quot;There is a lot of horsepower.&quot; be printed ? I am unsure if the System.out.println(&quot;There is a lot of horsepower&quot;); still qualifies as being part of the next statement of the first if condition.

Please advise. Thanks!
Indentation has absolutely no syntactic or semantic meaning in Java, and indeed in most popular languages (the main exception is Python).
Which if does your else belong to? This is an instance of the famous dangling else problem.
The syntax of Java associates each else to the innermost if, so the Java compiler understands your code in a way which is different than what your indentation suggests. If you want to associate the else with the outer if, you can use curly brackets.