ApexSensei

Drills Apex basics

Quick win: pick the larger number

if runs a block only when its test is true.

Your task

Fill in the body of larger so it returns a when a > b and b otherwise.

Integer larger(Integer a, Integer b) {
    return null;
}

Requirements

  1. larger(3, 9) should be 9
  2. larger(9, 3) should be 9
  3. larger(4, 4) should be 4
  4. larger(-1, -5) should be -1
  5. The method should be written with if, not Math.max(

Sign in to open this drill