A conditional

exercise No. 8

Create comment in forum


The following snippet only contains a main() method. Add a surrounding class and execute:

public static void main(String[] args) {

  int a = 3,
  b = 87;

  if (a < b) {
    System.out.println("a is smaller than b");
  } else if (b < a) {
    System.out.println("b is smaller than a");
  } else {
    System.out.println("b equals a");

Test different values for a and b reaching all three branches.