If Examples

File Name: IfExamples.java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
package basics.control_flow;

//Use if to specify a block of code to be executed, if a specified condition is true
public class IfExamples {
  public static void main(String[] args) {
    int a = 10;
    int b = 5;
    if (a > b) {
      System.out.println("10 is greater");
    }
    if (a < b) { //10 < 5 which is false
      System.out.println("This won't be printed because the statement is false");
    }
  }
}

// javac basics/statements/IfExamples.java && java basics.statements.IfExamples